-
$db = null; is NOT the way to go.
-
Get rid of all
try catch
operators. They just make mo sense. If you remove them, nothing would really change, because exceptions can report themselves, no assistance required, thank you -
Get git of all that
global
stuff. It's just gross. A class has its own means to persist the state. At least use astatic
variable to hold the connection. Better yet, do not use that static magic at all, create a regular instance with a constructor. -
Do not duplicate the code. All functions contain almost identical code. Reuse the functions, Luke!
public static function query($sqlquery, $inserts = array()){ $stmt = static::db->prepare($sqlquery); $stmt->execute($inserts); return $stmt; } public static function getDataRow($sqlquery, $inserts = array()){ return static::query($sqlquery, $inserts)->fetch(); } public static function getDataRows($sqlquery, $inserts = array()){ return static::query($sqlquery, $inserts)->fetchAll(); }
Created
May 19, 2020 05:13
-
-
Save colshrapnel/48fc5e76d8bfb1cd74b0a8bc917ea355 to your computer and use it in GitHub Desktop.
PDO wrapper review
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah ok I unterstand. thx