예제 #1
0
 /**
  * Convert a foreign key description into constraints on the Table object.
  *
  * @param TableSchema $table The table object to append
  *    a constraint to.
  * @param array $row The row data from `describeForeignKeySql`.
  * @return void
  */
 public function convertForeignKeyDescription(TableSchema $table, $row)
 {
     $data = ['type' => TableSchema::CONSTRAINT_FOREIGN, 'columns' => [$row['COLUMN_NAME']], 'references' => [$row['REFERENCED_TABLE_NAME'], $row['REFERENCED_COLUMN_NAME']], 'update' => $this->_convertOnClause($row['UPDATE_RULE']), 'delete' => $this->_convertOnClause($row['DELETE_RULE'])];
     $name = $row['CONSTRAINT_NAME'];
     $table->addConstraint($name, $data);
 }
예제 #2
0
 /**
  * Convert a foreign key description into constraints on the Table object.
  *
  * @param TableSchema $table The table object to append
  *    a constraint to.
  * @param array $row The row data from `describeForeignKeySql`.
  * @return void
  */
 public function convertForeignKeyDescription(TableSchema $table, $row)
 {
     $data = ['type' => TableSchema::CONSTRAINT_FOREIGN, 'columns' => $row['column_name'], 'references' => [$row['references_table'], $row['references_field']], 'update' => $this->_convertOnClause($row['on_update']), 'delete' => $this->_convertOnClause($row['on_delete'])];
     $table->addConstraint($row['name'], $data);
 }
예제 #3
0
 /**
  * Convert a foreign key description into constraints on the Table object.
  *
  * @param TableSchema $table The table object to append
  *    a constraint to.
  * @param array $row The row data from `describeForeignKeySql`.
  * @return void
  */
 public function convertForeignKeyDescription(TableSchema $table, $row)
 {
     $name = $row['from'] . '_fk';
     $update = isset($row['on_update']) ? $row['on_update'] : '';
     $delete = isset($row['on_delete']) ? $row['on_delete'] : '';
     $data = ['type' => TableSchema::CONSTRAINT_FOREIGN, 'columns' => [$row['from']], 'references' => [$row['table'], $row['to']], 'update' => $this->_convertOnClause($update), 'delete' => $this->_convertOnClause($delete)];
     if (isset($this->_constraintsIdMap[$table->name()][$row['id']])) {
         $name = $this->_constraintsIdMap[$table->name()][$row['id']];
     } else {
         $this->_constraintsIdMap[$table->name()][$row['id']] = $name;
     }
     $table->addConstraint($name, $data);
 }