Jump to content

Which one is better, MySQL or MySQLi?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
LuthfiHakim

LuthfiHakim

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 765 posts
So, if both are available, which one should I choose?

#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
MySQLi is newer than MySQL regarding php part, and has the possibility for a object oriented usage. I'd chose MySQLi.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
isuru

isuru

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 233 posts

Quote

The MySQLi Extension (MySQL Improved) is a relational database driver used in the PHP programming language to provide an interface with MySQL databases. MySQLi is an improved version of the older PHP MySQL driver, offering various benefits.[1] The developers of the PHP programming language recommend using MySQLi when dealing with MySQL server versions 4.1.3 and newer (takes advantage of new functionality).[1]

If I engage with php I would probably choose MySQLi.
Lost!

#4
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
Just note mysqli extension overhead is "huge", PDO_MySQL extension includes much richer feature set and its module is less than 1/5 the size, 1/2 of MySQL's.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#5
Guest_Benwell_*

Guest_Benwell_*
  • Guests
I would go with MySQLi, which is based on the Object Oriented concepts more efficient than MySQL.

Edited by Orjan, 01 December 2010 - 12:17 PM.
Removed spamlink


#6
LuthfiHakim

LuthfiHakim

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 765 posts
Sorry it took me so long to reply back, guys! Was having problem updating my computer.

Well, I am not a PHP programmer. My experience with PHP was only fixing some minor bugs and creating some "proxy" scripts (you know, using PHP to query/update database protected by webhosts). So I am not very familiar with the details. The reason I am asking is from end user perspective (ie. speed and maybe server load). I have several web sites and forums (to support my freeware users) which use CMS (Joomla and phpBB) which based on PHP. Each time I install them, I always been asked which one I want to use, MySQL or MySQLi.

So guys, what I need to know is from the end user perspective (i.e. speed) and maybe from the server itself (cpu load, hard drive read/write transactions), which one is the better one?

#7
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
The MySQL functions are native and outdated, dating before PHP had any good OO support, the only reason why MySQLi module was invented was to add support for prepared statements (that send literal quotes, so nothing can affect the query) and of course an OO interface of which to do business with.

You can easily compare this to "C vs C++" in speeds, except there is no backend optimizing compiler behind the scenes. If you do not require the features or security of MySQLi then it is quite a slow method of speaking with MySQL driver in a majority of cases. The lack of speed will only be incremental (i.e. a larger site with massive dataset), and people tend to move away from MySQL to a faster option if available (NoSQL, etc) at that point.

In any case implementing a good caching system will far outweigh the differences, as there will be simply no need to use the (slow|faster) DBMS system much on the harder hitting sites.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#8
LuthfiHakim

LuthfiHakim

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 765 posts
^ Okay, so let me sum up.

MySQL:
- Faster
- Lower grade security
- Its speed could easily beaten by a good caching system

MySQLi
- Slower
- Better grade security
- Good caching system will nullified its slower speed.

The conclusion is that I'll have to use MySQLi, since both joomla and phpBB have caching system which (I believe) are good. Anyone would like to add, in case I am missing something?

Thanks NullW0rm, everyone!