Migrations\View\Helper\MigrationHelper::primaryKeys PHP Метод

primaryKeys() публичный Метод

Returns the primary key data for a given table
public primaryKeys ( string $table ) : array
$table string Name of the table ot retrieve primary key for
Результат array
    public function primaryKeys($table)
    {
        $tableSchema = $table;
        if (!$table instanceof Table) {
            $tableSchema = $this->schema($table);
        }
        $primaryKeys = [];
        $tablePrimaryKeys = $tableSchema->primaryKey();
        foreach ($tableSchema->columns() as $column) {
            if (in_array($column, $tablePrimaryKeys)) {
                $primaryKeys[] = ['name' => $column, 'info' => $this->column($tableSchema, $column)];
            }
        }
        return $primaryKeys;
    }