findColumns() protected method

Collects the metadata of table columns.
protected findColumns ( yii\db\TableSchema $table ) : boolean
$table yii\db\TableSchema the table metadata
return boolean whether the table exists in the database
Example #1
0
 /**
  * @inheritdoc
  */
 protected function findColumns($table)
 {
     if (parent::findColumns($table)) {
         if (!count($table->primaryKey)) {
             foreach ($table->columns as $column) {
                 if (preg_match('~^pk_~', $column->name)) {
                     $table->primaryKey[] = $column->name;
                 }
             }
             if (!count($table->primaryKey)) {
                 foreach ($table->columns as $column) {
                     $table->primaryKey[] = $column->name;
                     break;
                 }
             }
         }
         return true;
     }
     return false;
 }