2016-10-12 2 views
0

나는 두 개의 db를 만들고 두 개의 db에서 두 개의 테이블을 조인했습니다. 구문 오류 또는 액세스 위반 : 사용자cakephp의 두 데이터베이스에서 두 테이블 조인

거부 ​​1142 SELECT 명령 내 코드 조인 쿼리 지역에서 작업하지만 라이브 서버에서 작업하지가

SQLSTATE 같은 오류가 [42000] 보여줍니다 질의 :

$holiday_workings = $this->CompoffEntry->find('all', array(

      'joins' => array(
        array(
          'table' => 'Meds.employee_details', 
          'alias' => 'Emp_det', 
          'type' => 'INNER', 
          'foreignKey' => false, 
          'conditions' => array('CompoffEntry.worked_on_period' => $holiday_period,'CompoffEntry.worked_on_date != ' => null,'CompoffEntry.employee_detail_id = Emp_det.employee_detail_id', 'Emp_det.emp_status = "A"',($department != 'all') ? 'Emp_det.department_id = '.$department : '',($roleId == 5) ? 'reporting_id = '.$user_id : ''), 
        ) 
      ) 
    )); 
+0

오류 자체가 설명하기가 쉽습니다. "SELECT 명령이 사용자에게 거부되었습니다" – Sefa

답변

0

작업 간단

SELECT * 
FROM Emp_det 
JOIN table_1 ON CompoffEntry.employee_detail_id = Emp_det.employee_detail_id 
WHERE Emp_det.emp_status = "A" 
AND 'Emp_det.department_id = '.$department : '' 
AND ($roleId == 5) ? 'reporting_id = '.$user_id : '' 
012를 만들기 위해 노력하고 외래 키를 사용하십시오 테이블을 조인

변수가 잘 초기화되고 코드가 예상대로 작동하는 값이 할당 될 때까지는 더 오래 걸립니다. 고맙습니다.