| @@ 906-936 (lines=31) @@ | ||
| 903 | * @return false|int |
|
| 904 | * <p>false on error</p> |
|
| 905 | */ |
|
| 906 | public function delete( |
|
| 907 | string $table, |
|
| 908 | $where, |
|
| 909 | string $databaseName = null |
|
| 910 | ) { |
|
| 911 | // init |
|
| 912 | $table = \trim($table); |
|
| 913 | ||
| 914 | if ($table === '') { |
|
| 915 | $this->debug->displayError('Invalid table name, table name in empty.', false); |
|
| 916 | ||
| 917 | return false; |
|
| 918 | } |
|
| 919 | ||
| 920 | if (\is_string($where)) { |
|
| 921 | $WHERE = $this->escape($where, false); |
|
| 922 | } elseif (\is_array($where)) { |
|
| 923 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 924 | } else { |
|
| 925 | $WHERE = ''; |
|
| 926 | } |
|
| 927 | ||
| 928 | if ($databaseName) { |
|
| 929 | $databaseName = $this->quote_string(\trim($databaseName)) . '.'; |
|
| 930 | } |
|
| 931 | ||
| 932 | $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})"; |
|
| 933 | ||
| 934 | $return = $this->query($sql); |
|
| 935 | ||
| 936 | \assert(\is_int($return) || $return === false); |
|
| 937 | ||
| 938 | return $return; |
|
| 939 | } |
|
| @@ 2364-2393 (lines=30) @@ | ||
| 2361 | * @return false|Result |
|
| 2362 | * <p>false on error</p> |
|
| 2363 | */ |
|
| 2364 | public function select( |
|
| 2365 | string $table, |
|
| 2366 | $where = '1=1', |
|
| 2367 | string $databaseName = null |
|
| 2368 | ) { |
|
| 2369 | // init |
|
| 2370 | $table = \trim($table); |
|
| 2371 | ||
| 2372 | if ($table === '') { |
|
| 2373 | $this->debug->displayError('Invalid table name, table name in empty.', false); |
|
| 2374 | ||
| 2375 | return false; |
|
| 2376 | } |
|
| 2377 | ||
| 2378 | if (\is_string($where)) { |
|
| 2379 | $WHERE = $this->escape($where, false); |
|
| 2380 | } elseif (\is_array($where)) { |
|
| 2381 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 2382 | } else { |
|
| 2383 | $WHERE = ''; |
|
| 2384 | } |
|
| 2385 | ||
| 2386 | if ($databaseName) { |
|
| 2387 | $databaseName = $this->quote_string(\trim($databaseName)) . '.'; |
|
| 2388 | } |
|
| 2389 | ||
| 2390 | $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})"; |
|
| 2391 | ||
| 2392 | $return = $this->query($sql); |
|
| 2393 | \assert($return instanceof Result || $return === false); |
|
| 2394 | ||
| 2395 | return $return; |
|
| 2396 | } |
|