Пример #1
0
 /**
  * @param  string $name
  * @return static
  */
 public function dropConstraint($name)
 {
     if (!empty($this->renameColumns)) {
         trigger_error('One statement must rename a column, other separate statements must change table definition.', E_USER_DEPRECATED);
         return $this;
     }
     return parent::dropConstraint($name);
 }
Пример #2
0
    /**
     * @covers Zend\Db\Sql\Ddl\AlterTable::getSqlString
     * @todo   Implement testGetSqlString().
     */
    public function testGetSqlString()
    {
        $at = new AlterTable('foo');
        $at->addColumn(new Column\Varchar('another', 255));
        $at->changeColumn('name', new Column\Varchar('new_name', 50));
        $at->dropColumn('foo');
        $at->addConstraint(new Constraint\ForeignKey('my_fk', 'other_id', 'other_table', 'id', 'CASCADE', 'CASCADE'));
        $at->dropConstraint('my_index');
        $expected = <<<EOS
ALTER TABLE "foo"
ADD COLUMN "another" VARCHAR(255) NOT NULL ,
CHANGE COLUMN "name" "new_name" VARCHAR(50) NOT NULL ,
DROP COLUMN "foo",
ADD CONSTRAINT "my_fk" FOREIGN KEY ("other_id") REFERENCES "other_table" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
DROP CONSTRAINT "my_index"
EOS;
        $this->assertEquals($expected, $at->getSqlString());
    }