Welcome Guest, Not a member yet? Register   Sign In
Can I use MySQLi instead of MySQL without any issue?
#1

[eluser]Unknown[/eluser]
Hello,

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

Thanks.
#2

[eluser]BrianDHall[/eluser]
MySQLi isn't a database: http://www.php.net/manual/en/intro.mysqli.php

Quote: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:

Code:
**
* 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';
#3

[eluser]Unknown[/eluser]
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.




Theme © iAndrew 2016 - Forum software by © MyBB