Yii CDB标准:如何从;第三条;有AR的桌子?
我有表格:司机、司机协商、基础协商和团队 在DriverController模型中,我希望获得驱动程序正在与之协商的团队id(位于基本协商中) 在驾驶员模型中,我有:Yii CDB标准:如何从;第三条;有AR的桌子?,yii,Yii,我有表格:司机、司机协商、基础协商和团队 在DriverController模型中,我希望获得驱动程序正在与之协商的团队id(位于基本协商中) 在驾驶员模型中,我有: 'driverNegotiation' => array(self::HAS_ONE, 'DriverNegotiation', 'driver_id') 在司机谈判中: 'baseNegotiation' => array(self::BELONGS_TO, 'BaseNegotiation', 'base_neg
'driverNegotiation' => array(self::HAS_ONE, 'DriverNegotiation', 'driver_id')
在司机谈判中:
'baseNegotiation' => array(self::BELONGS_TO, 'BaseNegotiation', 'base_negotiation_id')
在DriverController中,我构建了如下内容:
$criteria=new CDbCriteria(array(
'condition' => 'baseNegotiation.team_id=13',
'with' => 'driverNegotiation',
'together' => true,
));
但我得到:
Column not found: 1054 Unknown column 'baseNegotiation.team_id' in 'where clause'.
The SQL statement executed was: SELECT COUNT(DISTINCT `t`.`id`) FROM `driver` `t`
LEFT OUTER JOIN `driver_negotiation` `driverNegotiation` ON
(`driverNegotiation`.`driver_id`=`t`.`id`) WHERE (baseNegotiation.team_id=13)
因此,我可以从driver_nagotiation表中获取所有信息,但从一个表中无法获取任何信息
我需要使用join来获取正确的内容,还是有更好的方法
'with' => 'driverNegotiation.baseNegotiation'
这就成功了。
'with'=>'driverNegotiation.baseNegotiation'
。这正是我想要的!谢谢