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.
// 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.
Yesterday, December 8th, 2014 I took the Zend Certification exam and passed. The latest version of the Zend exam is based on PHP version 5.5. They have updated their syllabus to reflect this change. And also, Zend made their official study materiel available to buy from their website for $19.95. It was available free of cost before.
I took the decision to write the Zend certification about 2 years back. But things have changed so quick in my life that I couldn’t even prepare for the exam. I’ve seen a lot of posts on the internet about the tricks and tips to pass this exam, and a bunch of sample questions. So I am not going to write similar post. If you would like to pass the exam, here is my suggestion
Study Strings and Arrays thoroughly. Don’t just read those pages, write the code and try to execute. Use a pen and paper if you need. If you study almost all functions mentioned on those pages, you will certainly get 50% of the pass mark.
In addition to those, here is what I found, will give you additional points.
Continue reading “Passing Zend Certification Exam, Here is the tip!”
This is a simple php function for hashing a plain text password so that it can be saved into the database securely.
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.
This is a php code snippet that I wrote for a website. Thought it might be useful for some one else as I was unable to find any API to check whether the given email address is a free one or not.
There are thousands of websites provide free email address like Yahoo or Gmail.
This database has over 1000 free email id providers.
$email = $_REQUEST[’email’];
$data = json_decode(file_get_contents("http://vivekv.com/tools/freeemail/index.php?email=$email"),true);
The direct link to the API is
You’ll get a JSON encoded result. Converting it to array, you will get
[result] => true
[email] => firstname.lastname@example.org
[description] => yahoo.com is believed to be a free email provider
[provider] => yahoo.com
Result = True, means the email provider is a free email provider.
Hope this helps.