我用GII代碼生成主鍵,我想主鍵我怎樣才能在Yii中2 CRUD生成模板
C:\wamp\www\yii2\vendor\yiisoft\yii2-gii\generators\model/default/views/index.php
Yii中使用此代碼
$count = 0;
if (($tableSchema = $generator->getTableSchema()) === false) {
foreach ($generator->getColumnNames() as $name) {
if (++$count < 6) {
echo " '" . $name . "',\n";
} else {
echo " // '" . $name . "',\n";
}
}
} else {
foreach ($tableSchema->columns as $column) {
$format = $generator->generateColumnFormat($column);
if (++$count < 6) {
echo " '" . $column->name . ($format === 'text' ? "" : ":" . $format) . "',\n";
} else {
echo " // '" . $column->name . ($format === 'text' ? "" : ":" . $format) . "',\n";
}
}
}
而且我想在下面的代碼之前獲取primaryKey。
$ generator-> getTableSchema() - > primaryKey();
但無法正常工作。