|
16 | 16 | * |
17 | 17 | * - >getTablesList([$db] [,$pattern]) - returns tables list by SHOW TABLES request |
18 | 18 | * |
| 19 | + * - >createDatabase($db) - create new database with specified name |
| 20 | + * - >dropDatabase($db) - drop specified database and remove all tables inside |
19 | 21 | * - >getDatabasesList() - returns array contained names of existing Databases |
20 | 22 | * - >setCurrentDatabase($db [, $sess]) - set current database by 'USE db' request |
21 | 23 | * - >getCurrentDatabase([$sess]) - return results of 'SELECT currentDatabase()' |
@@ -436,16 +438,29 @@ public function setCurrentDatabase($db, $sess = null) |
436 | 438 | } |
437 | 439 | } |
438 | 440 |
|
439 | | - |
| 441 | + /** |
| 442 | + * Drop database and remove all tables inside it. |
| 443 | + * |
| 444 | + * @param type $db_name database name for drop (delete, remove) |
| 445 | + * @param boolean $if_exists Add condition "IF EXISTS" |
| 446 | + * @return false|string false if ok, or string with error description |
| 447 | + */ |
440 | 448 | public function dropDatabase($db_name, $if_exists = false) |
441 | 449 | { |
442 | | - $sql = "DROP DATABASE " . ($if_exists ? 'IF EXISTS ':''); |
| 450 | + $sql = "DROP DATABASE " . ($if_exists ? 'IF EXISTS ' : ''); |
443 | 451 | return $this->queryFalse($sql . $db_name); |
444 | 452 | } |
445 | 453 |
|
| 454 | + /** |
| 455 | + * Create new database |
| 456 | + * |
| 457 | + * @param string $db_name database name for create |
| 458 | + * @param boolean $if_not_exists Add condition "IF NOT EXISTS" |
| 459 | + * @return false|string false if ok, or string with error description |
| 460 | + */ |
446 | 461 | public function createDatabase($db_name, $if_not_exists = false) |
447 | 462 | { |
448 | | - $sql = "CREATE DATABASE " . ($if_not_exists ? 'IF NOT EXISTS ':''); |
| 463 | + $sql = "CREATE DATABASE " . ($if_not_exists ? 'IF NOT EXISTS ' : ''); |
449 | 464 | return $this->queryFalse($sql . $db_name); |
450 | 465 | } |
451 | 466 |
|
|
0 commit comments