0

最近、https://github.com/dereuromark/upgrade
を使用して 1.3 アプリを 2.4 にアップグレードしました が、$this->Model->find() の一部の使用法が機能しません。特に、関連付けられたモデル/テーブルへの結合。
「where句の不明な列 'Bill.customer_id'」という結果になります。

私のセットアップ:

テーブルと関連付け: http://i.stack.imgur.com/bjOIz.png (画像)

モデル:

App::uses('AppModel', 'Model');
class Customer extends AppModel {
public $actsAs = array('Logable', 'Containable');
public $hasMany = array(
    'Bill' => array(
        'className' => 'Bill',
        'foreignKey' => 'customer_id',
        'dependent' => false,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => '',
        'counterQuery' => ''
    )...
-----------------------------------------------------------------
App::uses('AppModel', 'Model');
class Bill extends AppModel {
public $actsAs = array('Containable', 'Logable', 'Lockable');

public $belongsTo = array(
    'Customer' => array(
        'className' => 'Customer',
        'foreignKey' => 'customer_id',
        'conditions' => '',
        'fields' => '',
        'order' => ''
    )...

public $hasAndBelongsToMany = array(
    'Stage' => array(
        'className' => 'Stage',
        'joinTable' => 'bills_stages',
        'foreignKey' => 'bill_id',
        'associationForeignKey' => 'stage_id',
        'unique' => true,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'finderQuery' => '',
        'deleteQuery' => '',
        'insertQuery' => ''
    )...
--------------------------------------------------------------
App::uses('AppModel', 'Model');
class BillsStage extends AppModel {
public $actsAs = array('Containable', 'Logable', 'Lockable');

public $belongsTo = array(
    'Bill' => array(
        'className' => 'Bill',
        'foreignKey' => 'bill_id',
        'conditions' => '',
        'fields' => '',
        'order' => ''
    ),
    'Stage' => array(
        'className' => 'Stage',
        'foreignKey' => 'stage_id',
        'conditions' => '',
        'fields' => '',
        'order' => ''
)...
--------------------------------------------------------
App::uses('AppModel', 'Model');
class Stage extends AppModel {
public $displayField = 'name';
public $actsAs = array('Tree', 'Containable', 'Logable');

public $hasMany = array(
    'Bill' => array(
        'className' => 'Bill',
        'foreignKey' => 'stage_id',
        'dependent' => false,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => '',
        'counterQuery' => ''
    )...

public $hasAndBelongsToMany = array(
    'Bill' => array(
        'className' => 'Bill',
        'joinTable' => 'bills_stages',
        'foreignKey' => 'stage_id',
        'associationForeignKey' => 'bill_id',
        'unique' => true,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'finderQuery' => '',
        'deleteQuery' => '',
        'insertQuery' => ''
    )...

1.3 では結合が機能しています。2.4 では 1 次元の SQL クエリのみ。

何か案が?

--編集--

$billsStages = $this->Customer->Bill->BillsStage->find('all', array(
  'conditions' => array(
      'Bill.customer_id' => $this->Customer->id,
      'Stage.id' => array_keys($vk_stages)
    ),
  'order' => 'BillsStage.created DESC'
));
4

1 に答える 1