findConstraints() protected method

Collects the foreign key column details for the given table.
protected findConstraints ( yii\db\TableSchema $table )
$table yii\db\TableSchema the table metadata
Example #1
0
 /**
  * @inheritdoc
  */
 protected function findConstraints($table)
 {
     parent::findConstraints($table);
     if (!count($table->foreignKeys)) {
         foreach ($table->columns as $column) {
             if (preg_match('~^(?:pk_|fk_|uk_|tk_)?(\\w+)_id$~', $column->name, $match) && $this->getTableSchema($match[1])) {
                 $table->foreignKeys[] = [$match[1], $match[0] => 'id'];
             }
         }
     }
 }