| @@ 888-918 (lines=31) @@ | ||
| 885 | * @return false|int |
|
| 886 | * <p>false on error</p> |
|
| 887 | */ |
|
| 888 | public function delete(string $table, $where, string $databaseName = null) |
|
| 889 | { |
|
| 890 | // init |
|
| 891 | $table = \trim($table); |
|
| 892 | ||
| 893 | if ($table === '') { |
|
| 894 | $this->debug->displayError('Invalid table name, table name in empty.', false); |
|
| 895 | ||
| 896 | return false; |
|
| 897 | } |
|
| 898 | ||
| 899 | if (\is_string($where)) { |
|
| 900 | $WHERE = $this->escape($where, false); |
|
| 901 | } elseif (\is_array($where)) { |
|
| 902 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 903 | } else { |
|
| 904 | $WHERE = ''; |
|
| 905 | } |
|
| 906 | ||
| 907 | if ($databaseName) { |
|
| 908 | $databaseName = $this->quote_string(\trim($databaseName)) . '.'; |
|
| 909 | } |
|
| 910 | ||
| 911 | $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})"; |
|
| 912 | ||
| 913 | $return = $this->query($sql); |
|
| 914 | ||
| 915 | \assert(\is_int($return) || $return === false); |
|
| 916 | ||
| 917 | return $return; |
|
| 918 | } |
|
| 919 | ||
| 920 | /** |
|
| 921 | * Ends a transaction and commits if no errors, then ends autocommit. |
|
| @@ 2279-2308 (lines=30) @@ | ||
| 2276 | * @return false|Result |
|
| 2277 | * <p>false on error</p> |
|
| 2278 | */ |
|
| 2279 | public function select(string $table, $where = '1=1', string $databaseName = null) |
|
| 2280 | { |
|
| 2281 | // init |
|
| 2282 | $table = \trim($table); |
|
| 2283 | ||
| 2284 | if ($table === '') { |
|
| 2285 | $this->debug->displayError('Invalid table name, table name in empty.', false); |
|
| 2286 | ||
| 2287 | return false; |
|
| 2288 | } |
|
| 2289 | ||
| 2290 | if (\is_string($where)) { |
|
| 2291 | $WHERE = $this->escape($where, false); |
|
| 2292 | } elseif (\is_array($where)) { |
|
| 2293 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 2294 | } else { |
|
| 2295 | $WHERE = ''; |
|
| 2296 | } |
|
| 2297 | ||
| 2298 | if ($databaseName) { |
|
| 2299 | $databaseName = $this->quote_string(\trim($databaseName)) . '.'; |
|
| 2300 | } |
|
| 2301 | ||
| 2302 | $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})"; |
|
| 2303 | ||
| 2304 | $return = $this->query($sql); |
|
| 2305 | \assert($return instanceof Result || $return === false); |
|
| 2306 | ||
| 2307 | return $return; |
|
| 2308 | } |
|
| 2309 | ||
| 2310 | /** |
|
| 2311 | * Selects a different database than the one specified on construction. |
|