PHP MySQLi Wrapper Class Update

Last December, I wrote a simple and easy to use PHP MySQLi wrapper class inspired from the simplicity of Code Igniter Active Record pattern and hosted on BitBucket. Over an year, I’ve been using this class and continuously improving it based on my requirements and other users requests. Over a dozen of bug fixes and improvements made based on user reporting so far.

The latest version has been released ( 1.4.6 ). This includes new methods FIND_IN_SET to find a value from a comma separated string and BETWEEN condition.

find_in_set('503', 'orders')->from('tblinvoices')->fetch();
// Produces: SELECT * FROM tblinvoices WHERE FIND_IN_SET ('305', orders)
$db->where('id', 5)->find_in_set('503', 'orders')->from('tblinvoices')->fetch();
// Produces: SELECT * FROM tblinvoices WHERE id='5' AND FIND_IN_SET ('305', orders)
$db->where('id', 5)->find_in_set('503', 'orders', 'OR')->from('tblinvoices')->fetch();
// Produces: SELECT * FROM tblinvoices WHERE id='5' OR FIND_IN_SET ('305', orders)

between('created', '2014-05-05', '2014-05-10');

// Produces: created BETWEEN '2014-05-05' AND '2014-05-10'

$db->from('tblinvoices')->where('clientid', '12')->between('created', '2014-05-05' , '2014-05-10')->fetch();

// Produces: SELECT * FROM tblinvoices WHERE clientid = '12' AND created BETWEEN '2014-05-05' AND '2014-05-10'

Download the latest version

View Documentation

I welcome comments and suggestions on this wrapper class and hope you will find it useful.

MySQLi Wrapper for PHP

I was very much interested in the database class of CodeIgniter, especially the Active Records.

I was quite satisfied with an old mysql wrapper that I have been using for long time. But I’ve decided to start using MySQLi for all my future projects so started to write my own database wrapper for php.

php.net official recommend the usage of mysqli over mysql if we are using MySQL database version 4.1.3 or more.

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 class has been made available online for free and is available at https://bitbucket.org/getvivekv/php-mysqli-class

For a complete documentation, refer https://bitbucket.org/getvivekv/php-mysqli-class/wiki/Home

The code was heavily inspired from CodeIgniter free library. The code is freely available for anyone to download. If you find any error or have any feature to add, please report me. You can also post new issue if you find any bug.