1 | <?php |
||
12 | trait SQLTrait |
||
13 | { |
||
14 | /** |
||
15 | * Initialize PDO connection |
||
16 | * |
||
17 | * @param PDO $pdo |null |
||
18 | * @return PDO |
||
19 | */ |
||
20 | private function pdoInitialize(PDO $pdo = null) |
||
27 | |||
28 | /** |
||
29 | * Create table |
||
30 | * |
||
31 | * @param PDO $pdo |
||
32 | * @param string $table |
||
33 | * @param string $query |
||
34 | * @return bool |
||
35 | */ |
||
36 | private function createTable(PDO $pdo, $table, $query) |
||
48 | |||
49 | /** |
||
50 | * Check if the table exists |
||
51 | * |
||
52 | * @param PDO $pdo |
||
53 | * @param string $table |
||
54 | * @return bool |
||
55 | */ |
||
56 | private function tableExists(PDO $pdo, $table) |
||
65 | } |
||
66 |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: