| @@ 864-890 (lines=27) @@ | ||
| 861 | * |
|
| 862 | * @throws QueryException |
|
| 863 | */ |
|
| 864 | public function delete(string $table, $where, string $databaseName = null) |
|
| 865 | { |
|
| 866 | // init |
|
| 867 | $table = \trim($table); |
|
| 868 | ||
| 869 | if ($table === '') { |
|
| 870 | $this->debug->displayError('Invalid table name, table name in empty.', false); |
|
| 871 | ||
| 872 | return false; |
|
| 873 | } |
|
| 874 | ||
| 875 | if (\is_string($where)) { |
|
| 876 | $WHERE = $this->escape($where, false); |
|
| 877 | } elseif (\is_array($where)) { |
|
| 878 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 879 | } else { |
|
| 880 | $WHERE = ''; |
|
| 881 | } |
|
| 882 | ||
| 883 | if ($databaseName) { |
|
| 884 | $databaseName = $this->quote_string(\trim($databaseName)) . '.'; |
|
| 885 | } |
|
| 886 | ||
| 887 | $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE)"; |
|
| 888 | ||
| 889 | return $this->query($sql); |
|
| 890 | } |
|
| 891 | ||
| 892 | /** |
|
| 893 | * Ends a transaction and commits if no errors, then ends autocommit. |
|
| @@ 2245-2271 (lines=27) @@ | ||
| 2242 | * |
|
| 2243 | * @throws QueryException |
|
| 2244 | */ |
|
| 2245 | public function select(string $table, $where = '1=1', string $databaseName = null) |
|
| 2246 | { |
|
| 2247 | // init |
|
| 2248 | $table = \trim($table); |
|
| 2249 | ||
| 2250 | if ($table === '') { |
|
| 2251 | $this->debug->displayError('Invalid table name, table name in empty.', false); |
|
| 2252 | ||
| 2253 | return false; |
|
| 2254 | } |
|
| 2255 | ||
| 2256 | if (\is_string($where)) { |
|
| 2257 | $WHERE = $this->escape($where, false); |
|
| 2258 | } elseif (\is_array($where)) { |
|
| 2259 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 2260 | } else { |
|
| 2261 | $WHERE = ''; |
|
| 2262 | } |
|
| 2263 | ||
| 2264 | if ($databaseName) { |
|
| 2265 | $databaseName = $this->quote_string(\trim($databaseName)) . '.'; |
|
| 2266 | } |
|
| 2267 | ||
| 2268 | $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE)"; |
|
| 2269 | ||
| 2270 | return $this->query($sql); |
|
| 2271 | } |
|
| 2272 | ||
| 2273 | /** |
|
| 2274 | * Selects a different database than the one specified on construction. |
|