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
I welcome comments and suggestions on this wrapper class and hope you will find it useful.