在 cakephp 中加入 table 时出错

error in joining table in cakephp

控制器

public function index(){ 
  $this->Store->unbindModel(
        array('belongsTo' => array('Employee')), true
    );

$options=array(             
        'joins' =>
                  array(
                    array(
                        'table' => 'Employee',
                        'alias' => 'Employee',
                        'foreignKey' => true,
                        'conditions'=> array('Employee.employee_store = Store.store_name')
                    )    
));
  $coupons = $this->Store->find('all', $options);
}

型号

class 商店扩展 AppModel { var $useTable = 'store'; }

Sql :

SELECT `Store`.`id`,
       `Store`.`store_name`,
       `Store`.`store_address`,
       `Store`.`store_phone`,
       `Store`.`store_email`,
       `Store`.`store_website`,
       `Store`.`date_enter`,
       `Store`.`store_shortcode`
FROM `billing`.`store` AS `Store`
JOIN `billing`.`Employee` AS `Employee` ON (`Employee`.`employee_store` = `Store`.`store_name`)
WHERE 1 = 1

我需要同时显示 Employee 和 Store table 列。 (employee_name、employee_mail 等来自员工 table、Store_name、store_add 来自商店 table)

$options = array(
            array(
                    'table' => 'Employee',
                    'alias' => 'Employee',
                    'foreignKey' => true,
                    'conditions'=> array('Employee.employee_store = Store.store_name')
                    )    
          );

$coupons = $this->Store->find('all',array(
   "fields"=>array("Employee.*","Store.*"),
   "joins"=>$options
));
$this->Store->Behaviors->load('Containable');
$options = array(
   'contain' => array(
      'Employee' => array(
          'conditions' => array(
              'Employee.employee_store' => 'Store.store_name'
          )
      )
   )
);
$coupons = $this->Store->find('all', $options);