开发者

Could I follow a MySQLi tutorial using MySQL?

开发者 https://www.devze.com 2023-03-14 11:09 出处:网络
There is a tutorial I\'d like to follow which has some great revi开发者_运维知识库ews. The only problem being it makes use of MySQLi instead of MySQL. I only have access to MySQL.

There is a tutorial I'd like to follow which has some great revi开发者_运维知识库ews. The only problem being it makes use of MySQLi instead of MySQL. I only have access to MySQL.

Are there big enough differences to warrant looking for a straight PHP-MySQL tutorial or is it worth just going with this one and making changes myself?

I would say I am a 'beginner' with both PHP and MySQL, but can find my way around the code fine, apply CRUD etc so not completely new.


MySQLi is PHP's "improved" MySQL driver. Meaning it will take full advantage of MySQL servers version higher than 4.1.3.

Then underlaying MySQL server would be the same, using the old MySQL interface or the newer MySQLi, so everthing should remain valid if you are following a MySQL tutorial on a MySQLi interface.

In your case, you should pay attention to MySQLi only stuff since they won't be avaliable to you.

Quote from the official website:

What is PHP's mysqli Extension?

The mysqli extension, or as it is sometimes known, the MySQL improved extension, was developed to take advantage of new features found in MySQL systems versions 4.1.3 and newer. The mysqli extension is included with PHP versions 5 and later.

The mysqli extension has a number of benefits, the key enhancements over the mysql extension being:

Object-oriented interface

Support for Prepared Statements

Support for Multiple Statements

Support for Transactions

Enhanced debugging capabilities

Embedded server support


It shouldn't be too hard to make the necessary adjustments. If you look at PHP's MySQL functions vs the MySQLi functions functions the main difference is that MySQLi is an object-oriented interface. Converting back to the regular MySQL functions is usually quite easy, for example: $rs->affected_rows becomes mysql_affected_rows($rs).

As @hexa pointed out, there are a couple things in MySQLi that the old interface doesn't support, such as prepared queries. If the tutorial involves those, it's not that hard to convert them to regular queries, it's just a bit of a hassle.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号