MySQL vs MySQLi vs Others? [SOLVED]

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
User avatar
vitinho444
Posts: 2825
Joined: Mon Mar 21, 2011 4:54 pm

MySQL vs MySQLi vs Others? [SOLVED]

Post by vitinho444 »

Hello PEEEEOOOPPLEEEEEEEEEEEEEEEEEEEE
(New intro like it?)

Ok, it might be a repost, so sorry halls and the team of Admins :S

I was checking on other forum (im not cheating on IR dont worry) and some guy talked about MySQLi... When i had my eyes covered, uncovered by Jacko mainly, that w3schools sucked, i was checking the mysql connection and they "teach" mysqli now instead of the old mysql.

My question is, should i use it from now on? They say it's OOP and to do a query is like: $query = $connection->query("UPDATE ..."); that looks much cooler than mysql_query("UPDATE..."); :roll:

Also.. i've been hearing about PDO and POSTGRE or something.. should i use those instead? I've always used phpmyadmin (thanks to halls, THANK YOU MAN, LOVE YOUR WORK) and i don't know if i might use a specific client like Navicat (i've used on some private game servers :P)...

What you guys think?
Last edited by vitinho444 on Wed Jul 03, 2013 10:43 am, edited 1 time in total.
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: MySQL vs MySQLi vs Others?

Post by Jackolantern »

The standard mysql driver should never be used. It has been deprecated in favor of mysqli. Mysqli has better performance and better security than mysql. Mysql also allows multiple queries to be run in one statement, which is a prime vector of SQL injection. Of course that doesn't excuse mysqli devs from forgetting about security, but should an accident occur, it is one less thing to worry about. And beyond that, mysql is deprecated, so it may be removed from a future version of PHP.

Then there is PDO. Technically, PDO could be called superior to mysqli, as it has more features, but since it covers more database types, they aren't technically in competition per se. Here is a breakdown of their comparison, but you can use whichever you want between mysqli and PDO.
The indelible lord of tl;dr
overras
Posts: 91
Joined: Sun Oct 03, 2010 7:25 am

Re: MySQL vs MySQLi vs Others?

Post by overras »

Use PDO . Your app/game will run on 11 types of databases.

Wiki :
Microsoft SQL Server ?i Sybase
Firebird/Interbase
IBM
Informix
MySQL
Oracle
ODBC ?i DB2
PostgreSQL
SQLite
4D

And about "cooler" code, you don't have to write a code to look "cool" . You must write the most efficient code you can , you can ask yourself these :

1.) If I want to update this in the future , how I should write this code? .
2.) Is possible my boss to ask me later to extend this to a bigger one, with other options and configurations. (So, you must rethink and rethink your script functionality).
3.) If I look in this script after 2-3 years , I will remember what every line does ?

So, you can start from php.net teaching PDO, good luck:)
User avatar
vitinho444
Posts: 2825
Joined: Mon Mar 21, 2011 4:54 pm

Re: MySQL vs MySQLi vs Others?

Post by vitinho444 »

overras wrote:Use PDO . Your app/game will run on 11 types of databases.

Wiki :
Microsoft SQL Server ?i Sybase
Firebird/Interbase
IBM
Informix
MySQL
Oracle
ODBC ?i DB2
PostgreSQL
SQLite
4D

And about "cooler" code, you don't have to write a code to look "cool" . You must write the most efficient code you can , you can ask yourself these :

1.) If I want to update this in the future , how I should write this code? .
2.) Is possible my boss to ask me later to extend this to a bigger one, with other options and configurations. (So, you must rethink and rethink your script functionality).
3.) If I look in this script after 2-3 years , I will remember what every line does ?

So, you can start from php.net teaching PDO, good luck:)
I just said cooler because indeed it's cooler xD But that doesn't matter of course.

But one question.. What makes me want to run on 11 types of dbs? and not just mysql?
Jackolantern wrote:The standard mysql driver should never be used. It has been deprecated in favor of mysqli. Mysqli has better performance and better security than mysql. Mysql also allows multiple queries to be run in one statement, which is a prime vector of SQL injection. Of course that doesn't excuse mysqli devs from forgetting about security, but should an accident occur, it is one less thing to worry about. And beyond that, mysql is deprecated, so it may be removed from a future version of PHP.

Then there is PDO. Technically, PDO could be called superior to mysqli, as it has more features, but since it covers more database types, they aren't technically in competition per se. Here is a breakdown of their comparison, but you can use whichever you want between mysqli and PDO.
I'm gonna delete the mysql then.. Now questions is PDO or Mysqli, my question still is what i did to overras : What makes me want to run on 11 types of dbs? and not just mysql?
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
Lord Rahl
Posts: 93
Joined: Fri May 17, 2013 2:51 pm

Re: MySQL vs MySQLi vs Others?

Post by Lord Rahl »

Learning PDO can be helpful if you run multiple projects on different database types (as in you run two sites, both PHP, however one is using mysql and one is not), however I have never had to switch a whole database for a project. PDO's main advantage if you're only ever using mysql isn't that. In my opinion it's not got a major advantage that makes it stick out in this case. It's a matter of choice.

OOP is available for both PDO, and mysqli read the tutorial linked above for details.

mysql_ shouldn't be used on new projects, and should slowly be moved away from, however I still have several older sites I have yet to upgrade. It's not yet become a problem (emphasis on the yet). I have used PDO on a few sites working with databases other then mysql, and tend to use it because I'm more comfortable using it then the extensions for other databases.
User avatar
vitinho444
Posts: 2825
Joined: Mon Mar 21, 2011 4:54 pm

Re: MySQL vs MySQLi vs Others?

Post by vitinho444 »

Lord Rahl wrote:Learning PDO can be helpful if you run multiple projects on different database types (as in you run two sites, both PHP, however one is using mysql and one is not), however I have never had to switch a whole database for a project. PDO's main advantage if you're only ever using mysql isn't that. In my opinion it's not got a major advantage that makes it stick out in this case. It's a matter of choice.

OOP is available for both PDO, and mysqli read the tutorial linked above for details.

mysql_ shouldn't be used on new projects, and should slowly be moved away from, however I still have several older sites I have yet to upgrade. It's not yet become a problem (emphasis on the yet). I have used PDO on a few sites working with databases other then mysql, and tend to use it because I'm more comfortable using it then the extensions for other databases.
I think I'll go with Mysqli :D I don't know if the PDO syntax is the same so i already know the mysqli that just needs an "i" in the end of the mysql functions right? :)
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
Lord Rahl
Posts: 93
Joined: Fri May 17, 2013 2:51 pm

Re: MySQL vs MySQLi vs Others?

Post by Lord Rahl »

vitinho444 wrote:
Lord Rahl wrote:Learning PDO can be helpful if you run multiple projects on different database types (as in you run two sites, both PHP, however one is using mysql and one is not), however I have never had to switch a whole database for a project. PDO's main advantage if you're only ever using mysql isn't that. In my opinion it's not got a major advantage that makes it stick out in this case. It's a matter of choice.

OOP is available for both PDO, and mysqli read the tutorial linked above for details.

mysql_ shouldn't be used on new projects, and should slowly be moved away from, however I still have several older sites I have yet to upgrade. It's not yet become a problem (emphasis on the yet). I have used PDO on a few sites working with databases other then mysql, and tend to use it because I'm more comfortable using it then the extensions for other databases.
I think I'll go with Mysqli :D I don't know if the PDO syntax is the same so i already know the mysqli that just needs an "i" in the end of the mysql functions right? :)
You can do that (e.g. http://uk3.php.net/mysqli_query ), however if you're updating anyway you should be looking into the things mysqli offers over mysql -> http://php.net/manual/en/mysqli.quickst ... ements.php
overras
Posts: 91
Joined: Sun Oct 03, 2010 7:25 am

Re: MySQL vs MySQLi vs Others?

Post by overras »

vitinho444 wrote:
I'm gonna delete the mysql then.. Now questions is PDO or Mysqli, my question still is what i did to overras : What makes me want to run on 11 types of dbs? and not just mysql?

Well, here can be many answers , but , let's say your boss will ask you to create a project on MSSQL or PostgreSQL, what you will do ? You will learn every syntax one by one? Acutally, is ok to learn them, but is not the best option when you have a deadline project. And anyway, you will be able to change the database type in every minute, just with 2 moves, but to understand this better, you must read what every type of database offer , you know, let's say MySQL vs MSSQL, then to choose what type is better for your project. Another best reason, you will sell your products with a big PLUS ( + ) when the customer will read "works on next database types: Microsoft SQL Server ?i Sybase, Firebird/Interbase,IBM,Informix,MySQL,Oracle,ODBC and DB2,PostgreSQL,SQLite,4D" .
User avatar
vitinho444
Posts: 2825
Joined: Mon Mar 21, 2011 4:54 pm

Re: MySQL vs MySQLi vs Others?

Post by vitinho444 »

Lord Rahl wrote:
vitinho444 wrote:
Lord Rahl wrote:Learning PDO can be helpful if you run multiple projects on different database types (as in you run two sites, both PHP, however one is using mysql and one is not), however I have never had to switch a whole database for a project. PDO's main advantage if you're only ever using mysql isn't that. In my opinion it's not got a major advantage that makes it stick out in this case. It's a matter of choice.

OOP is available for both PDO, and mysqli read the tutorial linked above for details.

mysql_ shouldn't be used on new projects, and should slowly be moved away from, however I still have several older sites I have yet to upgrade. It's not yet become a problem (emphasis on the yet). I have used PDO on a few sites working with databases other then mysql, and tend to use it because I'm more comfortable using it then the extensions for other databases.
I think I'll go with Mysqli :D I don't know if the PDO syntax is the same so i already know the mysqli that just needs an "i" in the end of the mysql functions right? :)
You can do that (e.g. http://uk3.php.net/mysqli_query ), however if you're updating anyway you should be looking into the things mysqli offers over mysql -> http://php.net/manual/en/mysqli.quickst ... ements.php
Yeah ofc i want to take all power from it :)
overras wrote:
vitinho444 wrote:
I'm gonna delete the mysql then.. Now questions is PDO or Mysqli, my question still is what i did to overras : What makes me want to run on 11 types of dbs? and not just mysql?

Well, here can be many answers , but , let's say your boss will ask you to create a project on MSSQL or PostgreSQL, what you will do ? You will learn every syntax one by one? Acutally, is ok to learn them, but is not the best option when you have a deadline project. And anyway, you will be able to change the database type in every minute, just with 2 moves, but to understand this better, you must read what every type of database offer , you know, let's say MySQL vs MSSQL, then to choose what type is better for your project. Another best reason, you will sell your products with a big PLUS ( + ) when the customer will read "works on next database types: Microsoft SQL Server ?i Sybase, Firebird/Interbase,IBM,Informix,MySQL,Oracle,ODBC and DB2,PostgreSQL,SQLite,4D" .
It is a big plus.. but question: Does my host allows PDO (how to check) and if yes, will i be allowed to use phpmyadmin to manage the DB's?
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
overras
Posts: 91
Joined: Sun Oct 03, 2010 7:25 am

Re: MySQL vs MySQLi vs Others?

Post by overras »

You can check if PDO driver is on the server with phpinfo(); on page, and yes, after you choose what type of database to use under PDO management, you will use the same software to manage the database ; mysql -> phpmyadmin in your case.

L.E: O yes, now 9/10 hosts have pdo installed so, its ok :)
Post Reply

Return to “Advanced Help and Support”