在cakephp中填充来自多个数据库的级联下拉列表

在cakephp中填充来自多个数据库的级联下拉列表,php,mysql,cakephp,cascadingdropdown,Php,Mysql,Cakephp,Cascadingdropdown,我有2个数据库,比如DB A和DB B,这里是概述: DB A有: - tbl_a - tbl_b - tbl_c - tbl_d DB B有: - tbl_a - tbl_b - tbl_c - tbl_d - tbl_x - tbl_y tbl_d有: - tbl_a - tbl_b - tbl_c - tbl_d tbl_a.id, tbl_b.id, tbl_c.id, tbl_x.id, tbl_y.name 我想使用级联下拉列表将数据添加到

我有2个数据库,比如DB A和DB B,这里是概述: DB A有:

 - tbl_a
 - tbl_b
 - tbl_c
 - tbl_d 
DB B有:

 - tbl_a
 - tbl_b
 - tbl_c
 - tbl_d 
 - tbl_x
 - tbl_y
tbl_d有:

 - tbl_a
 - tbl_b
 - tbl_c
 - tbl_d 
tbl_a.id, tbl_b.id, tbl_c.id, tbl_x.id, tbl_y.name
我想使用级联下拉列表将数据添加到tbl_d中 我已经成功地用
tbl_a.id
作为父对象制作了下拉列表,以获取
tbl_a.id、tbl_b.id、tbl_c.id
列表,但仍然无法获取
tbl_x.id
tbl_y.name
的数据

 - tbl_a
 - tbl_b
 - tbl_c
 - tbl_d 
我在尝试检索tbl_x.id列表时遇到了复杂性,因为:

 - tbl_a
 - tbl_b
 - tbl_c
 - tbl_d 
  • 数据库不同,但仍在1台服务器中,使用相同的用户名和密码
  • tbl_x仅与tbl_a相关,tbl_x.description=tbl_a.name
  • 以下是我在控制器中的附加功能:

     - tbl_a
     - tbl_b
     - tbl_c
     - tbl_d 
    
        public function add() {
        if ($this->request->is('post')) {
            $this->D->create();
    
    
            Controller::loadModel('C');
            $data = $this->C->find('first', array(
                'conditions' => array(
                    'C.id' => $this->request->data['D']['c_id']
                )
            ));
            $this->request->data['D']['c_name'] = $data['C']['name'];
    
    
                        $this->loadModel('X','Y');
                        $x = $this->X->find('list',array(
                            'conditions' => array(
                                'X.x_number' => $this->request->data['D']['x_no']
                            )
                        ));
                        $this->set('X',$x);
                        $y = $this->Y->find('list', array(
                            'conditions' => array(
                                'Y.code' => $this->request->data['D']['y_code']
                            )
                        ));
                        $this->set('Y',$y);
    
            if ($this->D->save($this->request->data)) {
                $this->Session->setFlash(__('The data has been saved.'), 'success');
                return $this->redirect(array('action' => 'index'));
            } else {
                $this->Session->setFlash(__('The data could not be saved. Please, try again.'));
            }
        }
        $a = $this->D->A->find('list');
    
        $types = array(
                'prepaid' => 'Prepaid',
                'postpaid' => 'Postpaid',
                'hybrid' => 'Hybrid'
        );
        $this->set(compact('a', 'types'));
    }
    
    以下是我的一些看法

     - tbl_a
     - tbl_b
     - tbl_c
     - tbl_d 
    
    <?php echo $this->Form->create('D'); ?>
    <?php
        echo $this->Form->input('a_id', array('empty' => '-- Select  --', 'default' => '-- Select  --'));
        echo $this->Form->input('b_id', array('empty' => '-- Select  --'));
        echo $this->Form->input('c_id', array('empty' => '-- Select  --'));
        echo $this->Form->input('x_no', array('options' => $x,
                    'class' => 'span5'));
        echo $this->Form->input('y');
        echo $this->Form->input('type');
    ?>
    <?php echo $this->Form->end(__('Submit')); ?>
    
    
    

    有人能告诉我该怎么做吗?

    看看这个问题:你到底有什么问题?您的问题是否
    $this->X->find
    未返回任何结果?如果是这样,您是否看到正在生成的SQL是否正确?另外,您需要告诉我们您使用的是哪个版本的Cakephp。我的问题是,当用户选择一个_id,然后表单输入x_no时,根据一个_id显示一些x_no列表。我已经做了一些sql查询测试,并给出了我想要的。我正在使用cakephp版本2.6改进的代码格式
     - tbl_a
     - tbl_b
     - tbl_c
     - tbl_d