<?php
class Product extends AppModel {
var $name = Product ;
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(
Category => array(
className => Category ,
foreignKey => category_id ,
conditions => ,
fields => ,
order =>
),
Brand
);
var $hasOne = array(
PhotoSmall => array(
className => Photo ,
foreignKey => product_id ,
dependent => true,
conditions => PhotoSmall.tipo = "small" ,
fields => ,
order => ,
limit => ,
offset => ,
exclusive => ,
finderQuery => ,
counterQuery =>
),
);
var $hasMany = array(
PhotoBig => array(
className => Photo ,
foreignKey => product_id ,
dependent => true,
conditions => PhotoBig.tipo = "big" ,
fields => ,
order => PhotoBig.order ,
limit => ,
offset => ,
exclusive => ,
finderQuery => ,
counterQuery =>
),
Rating => array(
className => Rating ,
foreignKey => product_id ,
dependent => false,
conditions => ,
fields => ,
order => ,
limit => ,
offset => ,
exclusive => ,
finderQuery => ,
counterQuery =>
)
);
我需要我的所有发现(除了行政区外)只检索有图像的产品。
在<代码>微量代码>的情况下,我可以做<代码>。 照片Small.id IS NOT NUL,其条件是:CakePhp产生左加入,但不能找到至少要求在上加入的办法。 照片Big
是因为Cake Php有两个问题要回去。
要求如下:我只能够展示带<条码>微量条码>的产品,并展示一个至少有一个<条码>的微量度/代码>广域(除网站行政部分外)的系统,解决办法应当与CakePhp pagination合作。
我尝试了以下法典,但没有成功,它只是回报产品数据,而不是光线数据:
$this->Product->recursive = -1;
$conditions = array( Product.category_id => $cats);
$joins = array(
array( table => photos ,
alias => PhotoBig ,
type => INNER ,
conditions => array(
Product.id = PhotoBig.product_id ,
)
),
array( table => photos ,
alias => PhotoSmall ,
type => INNER ,
conditions => array(
Product.id = PhotoBig.product_id ,
)
)
);
$this->paginate = array(
limit => 12,
conditions => $conditions,
joins => $joins,
);