EllisLab text mark
Advanced Search
     
Can I use MySQLi instead of MySQL without any issue?
Posted: 27 December 2009 01:07 AM
Avatar
Joined: 2009-12-02
2 posts

Hello,

I have a live site coded in CI. I heard MySQLi is much better, how can I switch without any issue?

Thanks.

 
Posted: 27 December 2009 02:02 AM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-10
778 posts

MySQLi isn’t a database: http://www.php.net/manual/en/intro.mysqli.php

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

CI uses a database abstraction layer, so if you want to use mysqli functionality - and I don’t know how it could be of any help, or harm for that matter - in config/database.php:

$db[‘default’][‘dbdriver’] = “mysql”;
becomes
$db[‘default’][‘dbdriver’] = “mysqli”;

...and that’s it, as far as I can tell. CI comes with an adapter/driver for mysqli, its just PHP5 only and less commonly used.

From the mysqli_driver.php:

**
 * 
MySQLi Database Adapter Class - MySQLi only works with PHP 5
 
*
 * 
Note_DB is an extender class that the app controller
 
creates dynamically based on whether the active record
 
* class is being used or not.
 *
 * @
package        CodeIgniter
 
* @subpackage    Drivers
 
* @category    Database
 
* @author        ExpressionEngine Dev Team
 
* @link        http://ellislab.com/codeigniter/user-guide/database/
 
*/
class 
CI_DB_mysqli_driver extends CI_DB {

    
var $dbdriver 'mysqli'
 Signature 

CreativeHalls Web Design and Printing
A few of my projects:
OurGulfCoast Property Management and Vacation Rental (ASP/.NET)
BukuBux - Money Saving Coupons and Gift Certificates (CodeIgniter, LAMP/MySQL)
Rentals800.com - Find a place to rent (CodeIgniter, LAMP/MySQL)
bdh (dot) hall (at) gmail (dotcom)

 
Posted: 27 December 2009 04:00 PM   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2009-12-02
2 posts

I know, MySQLi is a better database layer for PHP 5 and MySQL 4.1+. I was just wondering if I can switch only by changing the DB driver in database config file.

Thanks.