예제 #1
0
파일: Company.php 프로젝트: hkhateb/linet3
 public function delete()
 {
     //delete tables
     $connection = Yii::app()->db;
     //get connection
     $dbSchema = $connection->schema;
     //or $connection->getSchema();
     $tables = $dbSchema->getTableNames();
     //returns array of tbl schema's
     foreach ($tables as $tbl) {
         if (strpos($tbl, $this->prefix) === 0) {
             //echo $tbl->rawName, ":<br/>", implode(', ', $tbl->columnNames), "<br/>\n";
             //$dbSchema->dropTable($tbl);
             $command = $connection->createCommand($dbSchema->dropTable($tbl));
             $command->execute();
             // execute the non-query SQL
             //echo "holyshit:". $tbl . "<br/>\n";
         }
     }
     //delete folders
     $folder = $this->getFilePath($this);
     CFileHelper::removeDirectory($folder);
     //delete db perms
     return parent::delete();
 }