Possible Duplicate:
Advantages Of MySQLi over MySQL
I am building a large database and wondered which is the best to use?
I am sanitizing my values now and escaping characters for security but I would like to know the different benefits of these mysql querys in php?
Thanks.
Basically, MySQL is the old database driver, and MySQLi is the Improved driver. The "i" stands for "improved" so it is MySQL improved. MySQLi can be done procedural and object-oriented whereas MySQL can only be used procedurally. Mysqli also supports prepared statements which protect from SQL Injection.
Reasons why you should use MySQLi extension instead of the MySQL extension are many: MySQLi gives you prepared statements - a safer way of sending data to MySQL and protecting you from SQL injection. This alone should be enough for always choosing MySQLi over MySQL. MySQLi enables most of the MySQL features.
Yes – MySQLi has support for prepared statements in the underlying MySQL database. This support is provided through prepare, bind_param and execute methods of the MySQLi connection object.
Use MySQLi over the older MySQL functions. The "i" stands for "improved". The list of improvements can be found in the docs.
First of all, you better use PDO (as Lior suggested) or an intermediate layer (coded by you) between your code and the database functions provided by PHP, so that you can easily change mysql with mysqli or whatever your like without re-editing your whole code.
As of the differences, mysqli has more functionalities (there are a bunch of new functions) and is also object-oriented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With