本文整理汇总了PHP中ForeignKey::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP ForeignKey::delete方法的具体用法?PHP ForeignKey::delete怎么用?PHP ForeignKey::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ForeignKey
的用法示例。
在下文中一共展示了ForeignKey::delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUpdate
public function actionUpdate()
{
$isSubmitted = false;
$sql = false;
$foreignKey = ForeignKey::model()->findBySql('SELECT * FROM KEY_COLUMN_USAGE ' . 'WHERE TABLE_SCHEMA = :tableSchema ' . 'AND TABLE_NAME = :tableName ' . 'AND COLUMN_NAME = :columnName ' . 'AND REFERENCED_TABLE_SCHEMA IS NOT NULL', array('tableSchema' => $this->schema, 'tableName' => $this->table, 'columnName' => $this->column));
if (!$foreignKey) {
$foreignKey = new ForeignKey();
$foreignKey->TABLE_SCHEMA = $this->schema;
$foreignKey->TABLE_NAME = $this->table;
$foreignKey->COLUMN_NAME = $this->column;
}
if (isset($_POST['ForeignKey'])) {
$foreignKey->attributes = $_POST['ForeignKey'];
if ($foreignKey->getReferences() && ($sql = $foreignKey->save())) {
$isSubmitted = true;
} elseif (!$foreignKey->getReferences() && ($sql = $foreignKey->delete())) {
$isSubmitted = true;
}
}
CHtml::generateRandomIdPrefix();
// Column data
$columns = array('' => '');
$tables = Table::model()->findAllByAttributes(array('TABLE_SCHEMA' => $this->schema));
foreach ($tables as $table) {
if (StorageEngine::check($table->ENGINE, StorageEngine::SUPPORTS_FOREIGN_KEYS)) {
$columns[$table->TABLE_NAME] = array();
foreach ($table->columns as $column) {
$columns[$table->TABLE_NAME][$this->schema . '.' . $table->TABLE_NAME . '.' . $column->COLUMN_NAME] = $column->COLUMN_NAME;
}
}
}
// "On-Actions"
$onActions = array('' => '', 'CASCADE' => 'CASCADE', 'SET NULL' => 'SET NULL', 'NO ACTION' => 'NO ACTION', 'RESTRICT' => 'RESTRICT');
$this->render('form', array('foreignKey' => $foreignKey, 'columns' => $columns, 'onActions' => $onActions, 'sql' => $sql, 'isSubmitted' => $isSubmitted));
}
示例2: testDeleteIsNew
/**
* tries to delete a foreignkey which is new
* causes expection: cannot be deleted because it is new
* @expectedException CDbException
*/
public function testDeleteIsNew()
{
$foreignKey = new ForeignKey();
$foreignKey->TABLE_SCHEMA = 'tabletest';
$foreignKey->TABLE_NAME = 'product';
$foreignKey->COLUMN_NAME = 'fk';
$foreignKey->setReferences('tabletest.product_order.no');
$foreignKey->delete();
}