add notification if db info is correct but no tables in it
This commit is contained in:
parent
22b1f4ec41
commit
2c00e4fa67
|
|
@ -3,7 +3,7 @@
|
||||||
* @Author: printempw
|
* @Author: printempw
|
||||||
* @Date: 2016-02-02 21:59:06
|
* @Date: 2016-02-02 21:59:06
|
||||||
* @Last Modified by: prpr
|
* @Last Modified by: prpr
|
||||||
* @Last Modified time: 2016-02-02 23:48:47
|
* @Last Modified time: 2016-02-03 00:10:17
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class database
|
class database
|
||||||
|
|
@ -20,9 +20,20 @@ class database
|
||||||
utils::raise(-1, "Can not connect to mysql, check if database info correct in config.php. ".
|
utils::raise(-1, "Can not connect to mysql, check if database info correct in config.php. ".
|
||||||
$conn->connect_error);
|
$conn->connect_error);
|
||||||
}
|
}
|
||||||
|
if (!self::checkTableExist($conn)) {
|
||||||
|
utils::raise(-1, "Looks like that there is no `users` table in your database. ".
|
||||||
|
"Please run `/admin/install.php` first.");
|
||||||
|
}
|
||||||
return $conn;
|
return $conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function checkTableExist($conn) {
|
||||||
|
$sql = "SELECT table_name FROM
|
||||||
|
`INFORMATION_SCHEMA`.`TABLES` WHERE table_name ='users'
|
||||||
|
AND TABLE_SCHEMA='".DB_NAME."'";
|
||||||
|
return ($conn->query($sql)->num_rows != 0) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
public function query($sql) {
|
public function query($sql) {
|
||||||
$result = $this->connection->query($sql);
|
$result = $this->connection->query($sql);
|
||||||
if (!$this->connection->error) {
|
if (!$this->connection->error) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user