他们在PDO和MySQLi OOP方面有什么不同吗? [关闭]

Some examples...

MySQLi Connect

$mysqli = new mysqli('host', 'user', 'password', 'database');

PDO Connect

$pdo = new PDO("mysql:host=localhost;dbname=database", 'username', 'password');

MySQLi Query

$mysqli->query("INSERT INTO tabel (name) VALUES ('Peter')");

PDO Query

$pdo->query("INSERT INTO tabel (name) VALUES ('Peter')");

MySQLi Commit

$mysqli->commit();

PDO Commit

$pdo->commit();

So, what's actually the difference between and ? To me it's quite the same when coding.. Any difference in speed/safety/etc. ?

Is there any difference in PDO and MySQLi OOP?

Yes.
Just start actually using it and you will see.

In general, the only difference is that mysqli is a some sort of construction material for the higher level DB access library and shouldn't be used as is. While PDO is already sort of such a library and can be used as is.

Did you use google? PHP.net offers a detailed page exactly about this topic.

http://php.net/manual/en/mysqlinfo.api.choosing.php

The differences are in the keys (comparing mysql functionality):

API supports non-blocking, asynchronous queries with mysqlnd: Mysqli yes, PDO no

Supports all MySQL 5.1+ functionality: Mysqli yes, PDO most

API supports Multiple Statements: Mysqli yes, PDO most

But the key difference between mysqli and PDO is, you can also use PDO as an interface for SQLITE, Oracle, MS-SQL..... Mysqli only is for mysql