1 | <?php |
||
7 | class SqlDatabase implements DatabaseInterface |
||
8 | { |
||
9 | /** |
||
10 | * PDO instance. |
||
11 | * |
||
12 | * @var PDO |
||
13 | */ |
||
14 | protected $pdo; |
||
15 | |||
16 | /** |
||
17 | * Constructor. |
||
18 | * |
||
19 | * @param string $dsn |
||
20 | * @param string $user |
||
21 | * @param string $password |
||
22 | * @param null|array $options |
||
23 | */ |
||
24 | public function __construct($dsn, $user, $password, $options = null) |
||
35 | |||
36 | /** |
||
37 | * Get all rows from a $table specified by where. Only $columns are selected. |
||
38 | * |
||
39 | * @param string $table |
||
40 | * @param string $columns |
||
41 | * @param string|null $where |
||
42 | * |
||
43 | * @return array |
||
44 | */ |
||
45 | public function getRows($table, $columns, $where) |
||
59 | |||
60 | /** |
||
61 | * Update $column value with a $newValue. |
||
62 | * Update is performed on a row specified by $primaryValue of $table. |
||
63 | * |
||
64 | * @param string $table |
||
65 | * @param array $primaryKeyValue |
||
66 | * @param string $column |
||
67 | * @param mixed $value |
||
68 | * |
||
69 | * @return void |
||
70 | */ |
||
71 | public function updateByPrimary($table, $primaryKeyValue, $column, $value) |
||
85 | |||
86 | /** |
||
87 | * Build SQL where for key-value array. |
||
88 | * |
||
89 | * @param array $primaryKeyValue |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | protected function buildWhereForArray($primaryKeyValue) |
||
102 | } |
||
103 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: