07-11-2017, 03:14 PM
Code:
$customerQ = $db->query("SELECT * FROM customers")
Code:
$customers = $customerQ->results();
This doesn't make sense to me because $customerQ is not a copy of the object. Just use $db variable and check for error first. Otherwise $customers are going to be results from the previous query.
Code:
if (!$db->query("SELECT * FROM customers")->error())
Code:
$customers = $db->results();
In my version results are always cleared.
====
Also I'll hijack this thread to mention inconsistent return values. It's kinda weird to me that you can do this:
Code:
$array = $db->query(...)->results();
but not this:
Code:
$array = $db->get(...)->results();
I actually made a modification where it would always return object. However, I reverted it because there was no benefit for me. My queries have gotten complicated and I just use query() for getting data and rarely other functions.
EDIT: On the other hand returning bool forces you to check error which is a good practice.