| @@ 915-945 (lines=31) @@ | ||
| 912 | * @return false|int |
|
| 913 | * <p>false on error</p> |
|
| 914 | */ |
|
| 915 | public function delete( |
|
| 916 | string $table, |
|
| 917 | $where, |
|
| 918 | string $databaseName = null |
|
| 919 | ) { |
|
| 920 | // init |
|
| 921 | $table = \trim($table); |
|
| 922 | ||
| 923 | if ($table === '') { |
|
| 924 | $this->debug->displayError('Invalid table name, table name in empty.', false); |
|
| 925 | ||
| 926 | return false; |
|
| 927 | } |
|
| 928 | ||
| 929 | if (\is_string($where)) { |
|
| 930 | $WHERE = $this->escape($where, false); |
|
| 931 | } elseif (\is_array($where)) { |
|
| 932 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 933 | } else { |
|
| 934 | $WHERE = ''; |
|
| 935 | } |
|
| 936 | ||
| 937 | if ($databaseName) { |
|
| 938 | $databaseName = $this->quote_string(\trim($databaseName)) . '.'; |
|
| 939 | } |
|
| 940 | ||
| 941 | $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})"; |
|
| 942 | ||
| 943 | $return = $this->query($sql); |
|
| 944 | ||
| 945 | \assert(\is_int($return) || $return === false); |
|
| 946 | ||
| 947 | return $return; |
|
| 948 | } |
|
| @@ 2330-2359 (lines=30) @@ | ||
| 2327 | * @return false|Result |
|
| 2328 | * <p>false on error</p> |
|
| 2329 | */ |
|
| 2330 | public function select( |
|
| 2331 | string $table, |
|
| 2332 | $where = '1=1', |
|
| 2333 | string $databaseName = null |
|
| 2334 | ) { |
|
| 2335 | // init |
|
| 2336 | $table = \trim($table); |
|
| 2337 | ||
| 2338 | if ($table === '') { |
|
| 2339 | $this->debug->displayError('Invalid table name, table name in empty.', false); |
|
| 2340 | ||
| 2341 | return false; |
|
| 2342 | } |
|
| 2343 | ||
| 2344 | if (\is_string($where)) { |
|
| 2345 | $WHERE = $this->escape($where, false); |
|
| 2346 | } elseif (\is_array($where)) { |
|
| 2347 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 2348 | } else { |
|
| 2349 | $WHERE = ''; |
|
| 2350 | } |
|
| 2351 | ||
| 2352 | if ($databaseName) { |
|
| 2353 | $databaseName = $this->quote_string(\trim($databaseName)) . '.'; |
|
| 2354 | } |
|
| 2355 | ||
| 2356 | $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})"; |
|
| 2357 | ||
| 2358 | $return = $this->query($sql); |
|
| 2359 | \assert($return instanceof Result || $return === false); |
|
| 2360 | ||
| 2361 | return $return; |
|
| 2362 | } |
|