【发布时间】:2013-09-14 07:57:44
【问题描述】:
我有下表
create table `groupusers`(
`id` int not null auto_increment,
`user` varchar(100) not null,
`group` varchar(100) not null,
UNIQUE KEY(`id`),
PRIMARY KEY(`user`, `group`)
)
我的模型是这样的,
class Model_Groupuser extends ORM{
protected $_table_name = 'groupusers';
public function rules(){
return array(
'user' => array(
array('not_empty'),
array(array($this, 'user_group_not_exists')),
),
'group' => array(
array('not_empty'),
array(array($this, 'user_group_not_exists')),
)
);
}
public function user_group_not_exists($param){
// Need to get other field's value here.
}
}
问题是每次调用user_group_not_exists 时,都会使用单个参数调用它。用户或组。但我需要两者来确定数据库中是否已经存在该组合。
如何获取当前模型的字段值?
【问题讨论】:
标签: php mysql orm kohana kohana-3.2