Stats: 3,188,976 members, 7,936,133 topics. Date: Saturday, 31 August 2024 at 03:59 AM |
Nairaland Forum / Science/Technology / Programming / Most Used Mysql Database Functions (13324 Views)
Android Quiz App With Php And MYSQL Database / Web Development And Programming Using PHP/MYSQL Database At Yemlat / DHTMLSQL - A Very Advanced Wrapper For Mysql Database! (2) (3) (4)
Most Used Mysql Database Functions by bigdrey(m): 9:45pm On Jan 12, 2016 |
If you want to have a very powerful and interactive website then consider the use of web database either MYSQL or ORACLE just to mention a few. In this article we will see and explain most used mysql function which you may need and must know as a PHP Beginner and Programmer. Using PHP you can interact with MySQL database either using Mysql extension, PDO extension and MySQLI extension, for security reasons MySQL extension is considered as depreciated and it should not be used. In this article we will focus on MySQLI where ‘I’ means Improved. BUT WHAT IS MYSQL? This is an open source relation database management system (RDBMS) based on structured query language (SQL) WHY NEED MYSQLI This structured query language (SQL) provide an easy way to add, remove, alter and join information in database using standard SQL commands INSERT, DELETE, JOIN AND UPDATE. Let’s take a look on each function in detail. Before you can use MySQLI extension you may need to connect to database once, to connect to database you need to know few things about your database such as password, host, user and database name. HOST: This is where the database is located; it can be either localhost meaning your web server machine is hosting it's self the database or the database can be in another server. To connect to database which is on another server you use IP Address of the server otherwise you may use localhost (Self hosted database). CONNECTING TO DATABASE define(“HOST”,”localhost”); // our database host define(“USER”,”root”); // by default if mysql user name has not been changed the default is root define(“PASSWORD”,””); // database password define(“DB”,”test”); // our database to connect to $con = mysqli_connect(HOST,USER,PASSWORD,DB); if($con) die(“unable to connect to database”); Don’t forget to see how to create database and database table ADDING DATA TO DATABASE $query = “INSERT TO users (username,email,password) VALUES (‘user1’,’user0@gmail.com’,’password1’)"; // do not add comma (,) at the end $sql_execute = mysqli_query($query,$con); # check if MySQL executed successfully or not If(!$sql_execute){ die("unable to insert data into database" ![]() }else{ echo ("successfully added new record to database" ![]() } UPDATING DATA IN DATABASE $query = “UPDATE users SET email = ’user1@gmail.com’ WHERE email = ’user0@gmail.com’ LIMIT 1”; // Its always a good practice to add LIMIT when using update command, if more than one record match all will be updated $sql_execute = mysqli_query($query,$con); // let’s check if an update was successful If(mysqli_affected_rows($con) > 0){ echo = “Record updated”; }else{ die(“No record was updated”); } // if making alteration to a record with same info you may get an error DELETING DATA IN DATABASE - When performing this command you need to be careful as it can delete all records of the database and there is no undo $query = “DELETE FROM users WHERE email = ’user1@gmail.com’ LIMIT 1”; $ sql_execute = mysqli_query($query,$con); // let’s check if Delete was successful If(!$ sql_execute){ die (“Unable to delete file”); }else{ echo(“succefully deleted a file”); } Hint: for security reasons you are required to close MySQL connection when a query finishes but lucky MySQL usually do this for you when connection is not closed Don’t forget to check how to create simple but secure login script Don’t forget to check the power of OOP’s in PHP Source: http://blog.windrey.com/most_used_mysql_functions/ 10 Likes 2 Shares |
Re: Most Used Mysql Database Functions by Nobody: 12:57pm On Jan 14, 2016 |
This board no dey make frontpage again, it has been banned. |
Re: Most Used Mysql Database Functions by bigdrey(m): 1:25pm On Jan 14, 2016 |
dhtml18:Ehya too bad. Thanks for letting me know. Seems not everyone should have programming knowledge. 1 Like |
Re: Most Used Mysql Database Functions by Nobody: 2:02pm On Jan 14, 2016 |
ok |
Re: Most Used Mysql Database Functions by jaybee3(m): 2:04pm On Jan 14, 2016 |
Okies |
Re: Most Used Mysql Database Functions by labogini13(f): 2:04pm On Jan 14, 2016 |
want to create my blog |
Re: Most Used Mysql Database Functions by Abubakar247(m): 2:06pm On Jan 14, 2016 |
![]() ![]() |
Re: Most Used Mysql Database Functions by BUSHHUNTER: 2:07pm On Jan 14, 2016 |
Using Dreamweaver for programming html now 1 Like |
Re: Most Used Mysql Database Functions by emmyw(m): 2:07pm On Jan 14, 2016 |
Cool |
Re: Most Used Mysql Database Functions by mccoy47(m): 2:07pm On Jan 14, 2016 |
This made FP? 95% of nairalanders dont understand the poo u just wrote.. ![]() Click like if u understand. Click share if u don't 17 Likes 44 Shares |
Re: Most Used Mysql Database Functions by FagsamPHP(m): 2:08pm On Jan 14, 2016 |
well done op..... i know this looks like rubbish to many. 1 Like |
Re: Most Used Mysql Database Functions by html14java(f): 2:08pm On Jan 14, 2016 |
What are those. ![]() ![]() ![]() ![]() ![]() ![]() This kinda "writing in tongues" shouldn't make front page. Click the LIKE button as a SOLIDARITY warning to the Mods. and Share for number of lashes this Mod deserve 3 Likes 2 Shares |
Re: Most Used Mysql Database Functions by Chidizman(m): 2:09pm On Jan 14, 2016 |
MYSQL ![]() ![]() 1 Like |
Re: Most Used Mysql Database Functions by WebSurfer(m): 2:10pm On Jan 14, 2016 |
![]() |
Re: Most Used Mysql Database Functions by Nobody: 2:10pm On Jan 14, 2016 |
The Topic is different from the article. 1 Like |
Re: Most Used Mysql Database Functions by Afam4eva(m): 2:11pm On Jan 14, 2016 |
BUSHHUNTER:Really ![]() |
Re: Most Used Mysql Database Functions by JeffreyJamez(m): 2:16pm On Jan 14, 2016 |
lol this thread wont have more than 4 pages lol nice one op 1 Like |
Re: Most Used Mysql Database Functions by directonpc(m): 2:17pm On Jan 14, 2016 |
Nice job.
Guy you can try an android app I programmed http://7rl.in/png12 |
Re: Most Used Mysql Database Functions by Nobody: 2:17pm On Jan 14, 2016 |
Awesome bro... many won't understand this. That is the procedural version of mysqli. . You can use the Oop like $con = new Mysqli(); ![]() |
Re: Most Used Mysql Database Functions by shumuel(m): 2:19pm On Jan 14, 2016 |
Speak English please ![]() ![]() 1 Like |
Re: Most Used Mysql Database Functions by spicyuzo(m): 2:21pm On Jan 14, 2016 |
mccoy47:Because you don't understand it doesn't make it "poo"... Programmers across the globe are earning a living with this knowledge, Just so you know, this information is priceless.......for those who understand 1 Like 1 Share |
Re: Most Used Mysql Database Functions by Nobody: 2:37pm On Jan 14, 2016 |
mccoy47:Am as shocked as you are! but it is good sha. |
Re: Most Used Mysql Database Functions by Afam4eva(m): 2:47pm On Jan 14, 2016 |
Thos thread can barely even make 1 page. This section is in coma. |
Re: Most Used Mysql Database Functions by Nobody: 2:48pm On Jan 14, 2016 |
The weird world of a Programmer 1 Like |
Re: Most Used Mysql Database Functions by free2ryhme: 2:51pm On Jan 14, 2016 |
How many linda ikeji dey use ![]() make una dey complicate things for una selves ![]() |
Re: Most Used Mysql Database Functions by free2ryhme: 2:52pm On Jan 14, 2016 |
the thread dey beg for life ![]() too dry |
Re: Most Used Mysql Database Functions by imohchard(m): 2:54pm On Jan 14, 2016 |
So people still code websites? Wordpress and joomla don collect work frrom una hand na... CMS all the way... So I go code 25k Website? |
Re: Most Used Mysql Database Functions by Urine: 2:55pm On Jan 14, 2016 |
I remember the days I used to channel my queries like this, now Eloquent ti take over. |
Re: Most Used Mysql Database Functions by Urine: 2:56pm On Jan 14, 2016 |
imohchard: There are websites and Web Apps. |
Re: Most Used Mysql Database Functions by SupremeDimeji(m): 3:01pm On Jan 14, 2016 |
Na once in a year this kind thread dey make FP, till 2017 before we fit see this type again... ![]() |
Re: Most Used Mysql Database Functions by imohchard(m): 3:05pm On Jan 14, 2016 |
I know.. But you have ready made plugins in wp that does essential web app functions Urine: |
What Attracted You To Learn how to code? / In What Order Did You Learn Your Languages? / Javascript Study Group
Viewing this topic: 1 guest(s)
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 23 |