DboSource::alterSchema PHP Method

alterSchema() public method

Generate a alter syntax from CakeSchema::compare()
public alterSchema ( mixed $compare, string $table = null ) : boolean
$compare mixed The comparison data.
$table string The table name.
return boolean
    public function alterSchema($compare, $table = null)
    {
        return false;
    }

Usage Example

 /**
  * test alterSchema on two tables.
  *
  * @return void
  */
 public function testAlteringTwoTables()
 {
     $schema1 = new CakeSchema(array('name' => 'AlterTest1', 'connection' => 'test', 'altertest' => array('id' => array('type' => 'integer', 'null' => false, 'default' => 0), 'name' => array('type' => 'string', 'null' => false, 'length' => 50)), 'other_table' => array('id' => array('type' => 'integer', 'null' => false, 'default' => 0), 'name' => array('type' => 'string', 'null' => false, 'length' => 50))));
     $schema2 = new CakeSchema(array('name' => 'AlterTest1', 'connection' => 'test', 'altertest' => array('id' => array('type' => 'integer', 'null' => false, 'default' => 0), 'field_two' => array('type' => 'string', 'null' => false, 'length' => 50)), 'other_table' => array('id' => array('type' => 'integer', 'null' => false, 'default' => 0), 'field_two' => array('type' => 'string', 'null' => false, 'length' => 50))));
     $result = $this->Dbo->alterSchema($schema2->compare($schema1));
     $this->assertEquals(2, substr_count($result, 'field_two'), 'Too many fields');
 }
All Usage Examples Of DboSource::alterSchema
DboSource