What is difference between mysql,mysqli and pdo ?

http://php.net/manual/en/mysqli.overview.php

http://phppot.com/php/mysql-vs-mysqli-in-php/

There are (more than) three popular ways to use MySQL from PHP.

  1. (DEPRECATED) The mysql functions are procedural and use manual escaping.
  2. mysqli is a replacement for the mysql functions, with object-oriented and procedural versions. It has support for prepared statements.
  3. PDO (PHP Data Objects) is a general database abstraction layer with support for MySQL among many other databases. It provides prepared statements, and significant flexibility in how data is returned.

I would recommend using PDO with prepared statements. It is a well-designed API and will let you more easily move to another database (including any that supports ODBC) if necessary.

———————————————————

Those are differents API to access a MySQL backend

  • the mysql is the historical API
  • the mysqli is a new version of the historical API, it should perform better and have a better set of function, also the API is object oriented
  • PDO_MySQL, is the MySQL for PDO, PDO has been introduced in PHP, the project aims to make a common API for all the databases access, so in theory you should be able to migrate between RDMS without changing any code(if you don’t use specific RDBM function in your queries), also object oriented

So it depend what kind of code your want to produce, if you prefer object oriented layers or plain functions…

My advice would be

  1. PDO
  2. mysqli
  3. mysql

via

mysql-api

Κοινοποίηση

More From Author

+ There are no comments

Add yours

Time limit is exhausted. Please reload CAPTCHA.