我试图运行yii migrate,但它显示以下错误:
create table news-cate ...Exception: SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key
The SQL being executed was: CREATE TABLE `news-cate` (
`news-id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`cate-id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
class m150821_083020_create_newscate_table extends Migration
{
public function safeUp()
{
$this->createTable('news-cate', [
'news-id' => $this->primaryKey(),
'cate-id' => $this->primaryKey(),
]);
$this->addForeignKey("fk_news_cate_nid", "news-cate", "news-id", "news", "id", …Run Code Online (Sandbox Code Playgroud) 我正在使用Yii2的基本包.我创建了一个名为Admin的模块,我希望这个模块有自己的布局.但我不知道在哪里放置所有的CSS文件.然后,如何将它们包含在layout.php中.
我的目录结构:
basic
-- module
-- admin
-- controllers
-- DefaultController.php
-- views
-- default
-- layouts
-- main.php
-- css
-- style.css
Run Code Online (Sandbox Code Playgroud)
在main.php中,我使用此代码,但它不起作用:
<?php $this->registerLinkTag([
'rel' => 'stylesheet',
'href' => 'css/style.css',
]);
$this->head(); ?>
Run Code Online (Sandbox Code Playgroud)