cakephp cakePHP 1.3の多くのアソシエーションを持つモデルでfind( 'all' ...)を取得しようとします。スキーマ内の再帰の第2レベル。単純に、それはこのようになりますし、私はユーザーIDをフィルタリングしたい:ここcakePHP - 2回目の再帰でbelongsToを介してcantプルモデルアソシエート
Delivery belongsTo Order, Order belongsTo User.
はassocsです:
Order: var $belongsTo = array(
'User' => array( 'className' => 'User', 'foreignKey' => 'user_id', 'conditions' => '', 'fields' => '', 'order' => '' ),....
Delivery: var $belongsTo = array(
'Order' => array( 'className' => 'Order', 'foreignKey' => 'order_id', 'conditions' => '', 'fields' => '', 'order' => '' ),...
生じる誤差がある:ここでは
SQL Error: 1054: Unknown column 'User.id' in 'where clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 684]
フルクエリちょうど楽しみのために:
SELECT
Delivery
.id
,Delivery
.order_id
,Delivery
.delivery_address_id
,Delivery
.deliver_date
,Delivery
.created
,Delivery
.modified
,Delivery
.deliver_run
,Delivery
.product_mix_id1
,Delivery
.product_mix_id2
,Delivery
.product_mix_id3
,Delivery
.product_mix_id4
,Delivery
.assembled
,Delivery
.shipped
,Delivery
.rated
,Delivery
.price
,Delivery
.product_lines_id
,Order
.id
,Order
.user_id
,Order
.product_lines_id
,Order
.order_date
,Order
.deliver_monday
,Order
.deliver_tuesday
,Order
.deliver_wednessday
,Order
.deliver_thursday
,Order
.deliver_friday
,Order
.deliver_saturday
,Order
.delivery_address_id
,Order
.payment_delay
,Order
.active
,Order
.cancle_date
,Order
.replaced_order_id
,Order
.created
,Order
.modified
,DeliveryAddress
.id
,DeliveryAddress
.delivery_company
,DeliveryAddress
.delivery_title
,DeliveryAddress
.delivery_first_name
,DeliveryAddress
.delivery_last_name
,DeliveryAddress
.delivery_street
,DeliveryAddress
.delivery_house_nr
,DeliveryAddress
.delivery_postal_code
,DeliveryAddress
.delivery_town
,DeliveryAddress
.delivery_country
,DeliveryAddress
.created
,DeliveryAddress
.deleted
,DeliveryAddress
.modified
,ProductLine
.id
,ProductLine
.name
,ProductLine
.description
,ProductMix1
.id
,ProductMix1
.name
,ProductMix1
.description
,ProductMix1
.image_small_path
,ProductMix1
.image_normal_path
,ProductMix1
.product_categories_id
,ProductMix1
.depricated
,ProductMix1
.created
,ProductMix1
.modified
,ProductMix2
.id
,ProductMix2
.name
,ProductMix2
.description
,ProductMix2
.image_small_path
,ProductMix2
.image_normal_path
,ProductMix2
.product_categories_id
,ProductMix2
.depricated
,ProductMix2
.created
,ProductMix2
.modified
,ProductMix3
.id
,ProductMix3
.name
,ProductMix3
.description
,ProductMix3
.image_small_path
,ProductMix3
.image_normal_path
,ProductMix3
.product_categories_id
,ProductMix3
.depricated
,ProductMix3
.created
,ProductMix3
.modified
,ProductMix4
.id
,ProductMix4
.name
,ProductMix4
.description
,ProductMix4
.image_small_path
,ProductMix4
.image_normal_path
,ProductMix4
.product_categories_id
,ProductMix4
.depricated
,ProductMix4
.created
,ProductMix4
.modified
FROMdeliveries
ASDelivery
LEFT JOINorders
ASOrder
ON (Delivery
.order_id
=Order
.id
) LEFT JOINdelivery_addresses
ASDeliveryAddress
ON (Delivery
.delivery_address_id
=DeliveryAddress
.id
) LEFT JOINproduct_lines
ASProductLine
ON (Delivery
.product_lines_id
=ProductLine
.id
) LEFT JOINproduct_mixes
ASProductMix1
ON (Delivery
.product_mix_id1
=ProductMix1
.id
) LEFT JOINproduct_mixes
ASProductMix2
ON (Delivery
.product_mix_id2
=ProductMix2
.id
) LEFT JOINproduct_mixes
ASProductMix3
ON (Delivery
.product_mix_id3
=ProductMix3
.id
) LEFT JOINproduct_mixes
ASProductMix4
ON (Delivery
.product_mix_id4
=ProductMix4
.id
) WHEREUser
.id
= 1
誰もケーキが2番目のレベルを引っ張ってこない理由を知っていますか?この場合、ユーザーモデルは再帰的に5に設定されていますか?
多くのありがとうございます。
あなたはモデルのキャッシュ(複数可)を削除しようとしたことがありますか? – Ross