The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> MySQL vs MySQLi
Christian J
post Jul 3 2010, 03:39 PM
Post #1


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



Is there any point in learning MySQL today, or should you go straight to MySQLi?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies(1 - 6)
Brian Chandler
post Jul 3 2010, 07:59 PM
Post #2


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



What is MySQLi?

Remember that it's a good start to learn SQL, which you can use if you decide to use a different database engine, like the one you mentioned the other day (SQLite??)

So yes, there is a point in learning MySQL. It is not obvious that it's a question of going "straight to MySQLi" anymore than of going "straight to XHTML".
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jul 4 2010, 05:31 AM
Post #3


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



QUOTE(Brian Chandler @ Jul 4 2010, 02:59 AM) *

What is MySQLi?

http://www.php.net/manual/en/book.mysqli.php

I think the actual SQL is the same, but it seems you have to learn new related PHP functions, such as http://www.php.net/manual/en/mysqli.query.php instead of http://www.php.net/manual/en/function.mysql-query.php (it's not yet clear to me if all the old functions are replaced by new mysqli equivalents).
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Jul 4 2010, 01:24 PM
Post #4


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



Yes, it's just a new php interface to Mysql; I only skimmed, but it's a class, so gives you the advantages of OOP (object-oriented programming). But it isn't going to make any real difference to the mysql queries, and it's not likely that the conventional functions will simply disappear. If they did, there would be so many people who have large applications using those functions that someone would obviously write wrapper functions to get them back through the class interface.

And the functions all correspond anyway, so it really isn't a question of "learning" new function. (Surely you don't memorise these function details anyway? You just copy the last one, and check tricky bits in the manual.)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jul 4 2010, 05:28 PM
Post #5


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



QUOTE(Brian Chandler @ Jul 4 2010, 08:24 PM) *

it's not likely that the conventional functions will simply disappear.

As long as the new ones don't lack some feature of the old ones. I don't think you can mix MySQL and MySQLi functions with the same MySQLi connection (or can you?).

Can you use the old functions at all when MySQLi is enabled in php.ini? I guess I should test that myself, but in the meantime http://www.php.net/manual/en/mysqli.installation.php says

"With versions of PHP 5.3 and newer, you can alternatively use the new MySQL Native Driver with mysqli. This gives a number of benefits over using libmysql."

whatever that means (FWIW I don't have PHP5.3).

QUOTE
(Surely you don't memorise these function details anyway?

Some of it will always stick, so I'll probably minimize confusion by being consistent.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Jul 5 2010, 04:56 AM
Post #6


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



QUOTE(Christian J @ Jul 5 2010, 07:28 AM) *

QUOTE(Brian Chandler @ Jul 4 2010, 08:24 PM) *

it's not likely that the conventional functions will simply disappear.

As long as the new ones don't lack some feature of the old ones. I don't think you can mix MySQL and MySQLi functions with the same MySQLi connection (or can you?).


Why not? The database connection gives you a handle: both sets of functions use the handle to send requests to the database server. As long as they make sense the database server will respond appropriately.

It doesn't make sense to set out writing a bit of program with a jumble of different families of functions, but equally why should one function stop working (*how* *could* it stop working??) just because you are also calling other functions.

Remember that there is masses of code out there using the traditional php-mysql library. Programmers don't want this to "stop working" just because something else has been added. (Perhaps you have too much experience of the morass that is html-css, where having things stop working seems quite normal.)

QUOTE


Can you use the old functions at all when MySQLi is enabled in php.ini?



If the mysql library is installed, the functions will work. It is *inconceivable* (1) that they could mysteriously stop working because something else somewhere else has also been installed.

(1) Well, there are bugs, and things do not always work as advertised.

If you are new to this and learning, I would recommend using the traditional library, because you will find it much easier to get help with. If you are not currently learning to use classes and the rest of OOP, I *strongly* recommend using the traditional version. If you want to learn OOP later, going back to the mysql stuff and shifting it from procedural to OOP might be a good place to start.

HTH

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Ephraim F. Moya
post Jul 7 2010, 12:09 PM
Post #7


Advanced Member
****

Group: Members
Posts: 167
Joined: 2-September 07
From: New Mexico
Member No.: 3,702



I have learned over the years that improvements to php are really improvements.

I started using classes, including mysqli when I went to v5. It's better and I haven't found any downside. Use the newest stuff.

If you're NOT using classes -- start!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 09:37 PM