So I recently ran across a library that's apparently not well known.. It's called
MeekroDB. Basically it takes care of things like escaping parameters so I can do things like:
Code: Select all
$results = DB::query("SELECT * FROM some_table WHERE id > %i AND name != %s", 15, 'Sand');
foreach ($results as $result) {
echo $result['name'];
}
Or if I only need one field, I can do something like:
Code: Select all
$counter = DB::queryFirstField("SELECT COUNT(*) FROM some_table");
echo "We have $counter rows";
To me, that's soooooo much easier than what mysqli forces me to go through, and I don't need to escape stuff all the time. After switching to it, my script is a third shorter and much more readable.