1 | <?php |
||
11 | class MySql implements EnkiInterface |
||
12 | { |
||
13 | use LoggedClassTrait; |
||
14 | |||
15 | /** |
||
16 | * @var \PDO |
||
17 | */ |
||
18 | private $pdo; |
||
19 | |||
20 | /** |
||
21 | * Provides a MySQL connection interface that catches a PDOException on failure. |
||
22 | * |
||
23 | * @param string $host The host name for the MySQL connection |
||
24 | * @param string $user The username for the MySQL connection |
||
25 | * @param string $pass The password for the MySQL connection |
||
26 | * @param string $name The database name for the MySQL connection |
||
27 | * |
||
28 | * @return bool Returns true if the connection was successful; returns false otherwise |
||
29 | */ |
||
30 | 14 | public function connect($host, $user, $pass, $name) |
|
51 | |||
52 | /** |
||
53 | * Destroys an existing PDO connection |
||
54 | * |
||
55 | * @return bool Returns true if the connection existed and was destroyed; returns false otherwise |
||
56 | */ |
||
57 | 2 | public function disconnect() |
|
69 | |||
70 | /** |
||
71 | * Gets the column names for all primary keys for a table or returns false if no keys exist |
||
72 | * |
||
73 | * @param string $table The table from which keys will be retrieved |
||
74 | * |
||
75 | * @return mixed Returns an array of column names if the table has a compound primary key; |
||
76 | * returns a single column name if the table has only one primary key; |
||
77 | * returns false if the table has no primary keys |
||
78 | */ |
||
79 | 9 | public function getPrimaryKeys($table) |
|
111 | |||
112 | /** |
||
113 | * Retrieves a row represented by a single primary key |
||
114 | * |
||
115 | * @param int|string $id A unique id for a table |
||
116 | * @param string $table The table from which a row will be retrieved |
||
117 | * |
||
118 | * @return array|false Returns an associative array representing the row corresponding with the primary key; |
||
119 | * returns false if the table does not exist, if the provided id does not correspond with a |
||
120 | * record, or if the table has a compound primary key |
||
121 | */ |
||
122 | 5 | public function getRowById($id, $table) |
|
155 | |||
156 | /** |
||
157 | * Determines whether a given table exists |
||
158 | * |
||
159 | * @param string $table The table that will be checked for existence |
||
160 | * @return bool Returns true if the table exists; returns false otherwise |
||
161 | */ |
||
162 | 11 | public function tableExists($table) |
|
178 | } |
||
179 |