- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 Cake php 的新手。我在使用烘焙时遇到问题
我使用用户表设置了迁移
public $migration = array(
'up' => array(
'create_table' => array(
'users' => array(
'user_id' => array('type' => 'integer', 'null' => false, 'key' => 'primary'),
'username' => array('type' => 'string', 'null' => false, 'length' => 250),
'password' => array('type' => 'text', 'null' => false),
'created' => array('type' => 'string', 'null' => false, 'length' => 14),
'modified' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 14),
'indexes' => array(
'PRIMARY' => array('column' => 'user_id', 'unique' => 1)
)
)
)
),
'down' => array(
'drop_table' => array(
'users'
)
)
);
并将此文件迁移到数据库上,然后我尝试执行命令“蛋糕烘焙全部”问题是 User 使用 ownTo 和 hasMany 引用了自身这是默认使用烘焙吗?
class User extends AppModel {
/**
* Validation rules
*
* @var array
*/
public $validate = array(
'user_id' => array(
'numeric' => array(
'rule' => array('numeric'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'username' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'date_created' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
);
//The Associations below have been created with all possible keys, those that are not needed can be removed
/**
* belongsTo associations
*
* @var array
*/
public $belongsTo = array(
'User' => array(
'className' => 'User',
'foreignKey' => 'user_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
/**
* hasMany associations
*
* @var array
*/
public $hasMany = array(
'User' => array(
'className' => 'User',
'foreignKey' => 'user_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
}
我在这里缺少什么吗?我应该保留它并手动修改它还是有一个我错过的配置。
最佳答案
有三个简单的解决方案,正如最后一个答案所述,蛋糕烘焙都是遵循默认的蛋糕约定,并通过表中的 user_id 创建关联
将数据库字段从 user_id
重命名为 id
,然后再次运行 shell。
运行蛋糕烘焙
并手动选择模型并使用 shell 助手手动配置数据库关联
关于php - CakePHP烘焙所有未知问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26739981/
有人可以告诉我为什么这不起作用: $(document).ready(function() { $("#cookie").text("expanded"); //panel toggl
我通过终端命令生成(烘焙) Controller : bin/cakebake.bake Controller [controller_name] 是否有命令可以反转它?要删除生成的 Controll
我一直在查看说明书中的文档以在烘焙 View 中生成自定义 HTML,但我很难让我的自定义代码在烘焙过程中运行。 我按照说明进行了操作,这些说明是: 修改“烘焙”模板生成的默认 HTML¶ 如果您希望
我正在尝试执行 Simple Acl controlled Application cakephp 食谱中的教程。这个想法是: 制作数据库 CREATE TABLE users ( id INT(
我是一名优秀的程序员,十分优秀!