Example #1
0
function get_table_create($table)
{
    $db = new db();
    $sql = "DESCRIBE {$table}";
    return $db->selectQuery($sql);
}
Example #2
0
 /**
  * Checks if any table exist in database
  * @return boolean
  */
 public static function tablesExists()
 {
     $db = new db();
     $ret = $db->connect(array('dont_die' => 1));
     if ($ret == 'NO_DB_CONN') {
         return false;
     }
     $info = admin::getDbInfo();
     if (!$info) {
         common::echoMessage('No databse url in config.ini');
     }
     if ($info['scheme'] == 'mysql' || $info['scheme'] == 'mysqli') {
         $rows = $db->selectQuery("SHOW TABLES");
         if (empty($rows)) {
             return false;
         }
         return true;
     }
     if ($info['scheme'] == 'sqlite') {
         $sql = "SELECT name FROM sqlite_master WHERE type='table' AND name='modules'";
         $rows = $db->selectQuery($sql);
         if (empty($rows)) {
             return false;
         }
         return true;
     }
 }
Example #3
0
 /**
  * clone a complete database
  * @param string $database
  * @param string $newDatabase
  * @return boolean $res
  */
 public static function cloneDB($database, $newDatabase)
 {
     $db = new db();
     $rows = $db->selectQuery('show tables');
     $tables = array();
     foreach ($rows as $table) {
         $tables[] = array_pop($table);
     }
     $db->rawQuery("CREATE DATABASE `{$newDatabase}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
     foreach ($tables as $cTable) {
         self::changeDB($newDatabase);
         $create = $db->rawQuery("CREATE TABLE {$cTable} LIKE " . $database . "." . $cTable);
         if (!$create) {
             $error = true;
         }
         $db->rawQuery("INSERT INTO {$cTable} SELECT * FROM " . $database . "." . $cTable);
     }
     return !isset($error) ? true : false;
 }