Example #1
0
 /**
  * Change the prefix back to the original.
  * @param bool $dropTables Optionally drop the tables we created
  */
 public function destroy($dropTables = false)
 {
     if ($dropTables) {
         self::changePrefix($this->newTablePrefix);
         foreach ($this->tablesToClone as $tbl) {
             $this->db->dropTable($tbl);
         }
     }
     self::changePrefix($this->oldTablePrefix);
 }
 function remove($dbs)
 {
     echo "Remove Duplicate Row\n\n";
     $db = new Database();
     $conn = $db->connectDatabase();
     foreach ($dbs as $dbname) {
         $db->selectDatabase($conn, $dbname);
         $db->createTmpTable($conn, "products");
         $db->insertIntoTmp($conn, "products");
         $db->dropTable($conn, "products");
         $db->renameTable($conn, "products");
         echo $dbname . "\n";
     }
 }
Example #3
0
 /**
  * If the specified table exists, drop it, or execute the
  * patch if one is provided.
  *
  * Public @since 1.20
  *
  * @param string $table Table to drop.
  * @param string|bool $patch String of patch file that will drop the table. Default: false.
  * @param bool $fullpath Whether $patch is a full path. Default: false.
  * @return bool False if this was skipped because schema changes are skipped
  */
 public function dropTable($table, $patch = false, $fullpath = false)
 {
     if (!$this->doTable($table)) {
         return true;
     }
     if ($this->db->tableExists($table, __METHOD__)) {
         $msg = "Dropping table {$table}";
         if ($patch === false) {
             $this->output("{$msg} ...");
             $this->db->dropTable($table, __METHOD__);
             $this->output("done.\n");
         } else {
             return $this->applyPatch($patch, $fullpath, $msg);
         }
     } else {
         $this->output("...{$table} doesn't exist.\n");
     }
     return true;
 }
Example #4
0
 /**
  * database connection test.
  */
 public function test_database_connection()
 {
     $name = "test_database_connection";
     $db = new Database();
     test($db->getDatabaseObject());
     if ($db->tableExists($name)) {
         $db->dropTable($name);
     }
     // table exists
     test($db->tableExists($name) == FALSE);
     $db->createTable($name);
     test($db->tableExists($name));
     // quote
     // @Attention 반드시 아래의 quote 가 통과를 해야 한다.
     $ret_str = $db->quote("str");
     test($ret_str == "'str'", '', 'Quote failed...');
     $ret_str = $db->quote("st'r");
     test($ret_str == "'st''r'", '', 'Quote failed...');
     // table drop
     $db->dropTable($name);
     test($db->tableExists($name) == FALSE);
 }
Example #5
0
 /**
  *
  */
 public function clean()
 {
     if ($this->exists()) {
         self::$db->dropTable($this->name());
     }
 }