Difference between mysqli and mysql? [duplicate]

2019-02-05 05:20发布

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.

标签: php mysql mysqli
5条回答
Viruses.
2楼-- · 2019-02-05 05:41

From my point of view, the main difference (improvement) is that mysqli lets you execute multiple queries; that in turn allows you to execute (and retrieve results from) stored procedures with out parameters or which return resultset.

I do agree with others that using PDO is a better choice though.

查看更多
淡お忘
3楼-- · 2019-02-05 05:41

For all those saying to use PDO. Is it only for the prepared statements? Because you can do prepared statements in mySQLi without PDO. Just FYI.

查看更多
等我变得足够好
4楼-- · 2019-02-05 05:47

Why not use PDO instead? You have the benefit of prepared statements amongst other features there and it would prove to be a wise decision should you decide to move to another DB one day.

http://php.net/manual/en/book.pdo.php

If you insist on using one of the options mentioned above, MySQLi is basically a more Object Oriented approach to the standard mysql extension. For the most part, they are functionality-wise the same. If you're building an OOP based application, MySQLi would probably be a wiser, more consistent choice.

查看更多
The star\"
5楼-- · 2019-02-05 05:50

Use MySQLi over the older MySQL functions. The "i" stands for "improved". The list of improvements can be found in the docs.

查看更多
放我归山
6楼-- · 2019-02-05 05:51

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.

查看更多
登录 后发表回答