我正在使用cakephp 2.1.1。 这是我的表格关联:x hasmany y hasmany z hasmany w。
我认为一切都是正确设置但是当我提出这个问题时:
$conditions = array(
'contain' => array(
'y' => array (
'z' => array(
'w'=> array(
'conditions' => array('col>=' => $q))
)
)
));
$this->loadmodel('x');
$o=$this->x->find('all',$conditions);//array(
debug($o);
我没有我想要的结果;只提取表x!为什么? 例如,这是我的模型x php代码,与其他代码类似:
<? php
class x extends AppModel
{
var $name='x';
public $actsAs = array('Containable');
public $hasMany = array( 'y');
}
也许是cakephp版本?
谢谢!
info:我想这样说:
select z.col1, y.col2, x.col3
from z, y, x, w
where w.col>= 3
and w.z_id = z.id
and z.y_id = y.id
and z.x_id = x.id