DboSource::dropSchema PHP Method

dropSchema() public method

Generate a "drop table" statement for the given Schema object
public dropSchema ( CakeSchema $schema, string $table = null ) : string
$schema CakeSchema An instance of a subclass of CakeSchema
$table string Optional. If specified only the table name given will be generated. Otherwise, all tables defined in the schema are generated.
return string
    public function dropSchema(CakeSchema $schema, $table = null)
    {
        $out = '';
        if ($table && array_key_exists($table, $schema->tables)) {
            return $this->_dropTable($table) . "\n";
        } elseif ($table) {
            return $out;
        }
        foreach (array_keys($schema->tables) as $curTable) {
            $out .= $this->_dropTable($curTable) . "\n";
        }
        return $out;
    }

Usage Example

Example #1
0
 /**
  * testDropSchemaNoSchema method
  *
  * @expectedException PHPUnit_Framework_Error
  * @throws PHPUnit_Framework_Error
  * @return void
  */
 public function testDropSchemaNoSchema()
 {
     try {
         $this->Dbo->dropSchema(null);
     } catch (Throwable $t) {
         throw new PHPUnit_Framework_Error($t);
     }
 }
All Usage Examples Of DboSource::dropSchema
DboSource