【发布时间】:2014-01-26 22:30:03
【问题描述】:
我是初学者并搜索过文档,但找不到如何执行此操作:
我有两个表,admin 和 application。管理员可以有许多应用程序。
管理员:
class Model_Admin extends Model_Table {
public $entity_code='admin';
function init(){
parent::init();
$this->addField('name');
$this->addField('email');
$this->addField('password')->type('password');
$this->addField('active')->type('boolean')->system(true);
$this->addField('super')->type('boolean')->system(true);
$this->addField('created')->type('timestamp')->defaultValue($this->dsql()->expr('now()'))->system(true);
$this->addField('updated')->type('timestamp')->system(true);
$this->hasMany('Application','admin_id');
//$this->hasOne('Application');
$this->addHook('beforeSave',function($m){
$m['updated']=$m->dsql()->expr('now()');
});
}
}
应用:
class Model_Application extends Model_Table {
public $entity_code='application';
function init(){
parent::init();
$this->addField('name');
$this->addField('fbid');
$this->addField('fbsecret');
$this->addField('active')->type('boolean')->system(true);
$this->addField('created')->type('timestamp')->system(true);
$this->addField('updated')->type('timestamp')->system(true);
}
}
第一个问题,当我生成 SQL 代码 (/generate.html) 时,它不会为一对多关系生成任何东西。 其次,在一个页面上我添加了 CRUD:
$this->add('CRUD')->setModel('Admin');
但是没有任何一对多的提示。我希望它在添加按钮表单上,但也没有什么?
我想要的是,我可以添加管理员,并选择属于它的应用程序?
【问题讨论】:
标签: atk4