2012-09-11 2 views
0

데이터베이스의 여러 테이블을 PDO 및 UPDATING으로 사용하고 있습니다.쿼리 실패 : SQLSTATE [HY093] : 잘못된 매개 변수 번호 : 바인딩 된 변수 수가 토큰 수와 일치하지 않습니다.

쿼리 실패 : 나는 다음과 같은 오류가 발생 쿼리를 실행할 때마다 SQLSTATE [HY093] : 잘못된 매개 변수 번호 : 토큰의 바운드 변수의 개수가 일치하지 않을 수

내가 겪었 및 확인과 한 올바른 것으로 보인다. 어려운 값으로 PHPMyAdmin에서 쿼리를 실행할 수 있으며 테이블을 업데이트합니다. 테스트를 위해 테이블 ​​이름을 하드 코딩했습니다.

   $conn = parent::connect(); 
      $sql = "UPDATE ds_employee 
        LEFT OUTER JOIN ds_employee_address ON ds_employee.id_employee = ds_employee_address.fk_employee 
        LEFT OUTER JOIN ds_employee_detail ON ds_employee.id_employee = ds_employee_detail.fk_employee 
        SET 
         ds_employee.emp_lastname = :emp_lastname, 
         ds_employee.emp_firstname = :emp_firstname, 
         ds_employee.emp_middlename = :emp_middlename, 
         ds_employee.emp_prefername = :emp_prefername, 
         ds_employee_address.address1 = :address1, 
         ds_employee_address.address2 = :address2, 
         ds_employee_address.city = :city, 
         ds_employee_address.state = :state, 
         ds_employee_address.postal_code = :postal_code, 
         ds_employee_address.country = :country, 
         ds_employee_detail.hphone = :hphone, 
         ds_employee_detail.wphone = :wphone, 
         ds_employee_detail.mphone = :mphone, 
         ds_employee_detail.emp_email = :emp_email, 
         ds_employee_detail.gender = :gender, 
         ds_employee_detail.DOB = :DOB, 
         ds_employee_detail.ssn = :ssn, 
         ds_employee_detail.ethnicity = :ethnicity, 
         ds_employee_detail.filing_staus = :filing_status, 
         ds_employee_detail.emp_sdate = :emp_sdate, 
         ds_employee_detail.fk_department = :fk_department, 
         ds_employee_detail.job_title = :job_title, 
         ds_employee_detail.fk_manager = :fk_manager, 
         ds_employee_detail.drug_test = :drug_test, 
         ds_employee_detail.bg_check = :bg_check 
        WHERE ds_employee.id_employee = :id_employee"; 

      try { 
       $st = $conn->prepare($sql); 
       $st->bindValue(":emp_lastname", $this->data["emp_lastname"], PDO::PARAM_STR); 
       $st->bindValue(":emp_firstname", $this->data["emp_firstname"], PDO::PARAM_STR); 
       $st->bindValue(":emp_middlename", $this->data["emp_middlename"], PDO::PARAM_STR); 
       $st->bindValue(":emp_prefername", $this->data["emp_prefername"], PDO::PARAM_STR); 
       $st->bindValue(":address1", $this->data["address1"], PDO::PARAM_STR); 
       $st->bindValue(":address2", $this->data["address2"], PDO::PARAM_STR); 
       $st->bindValue(":city", $this->data["city"], PDO::PARAM_STR); 
       $st->bindValue(":state", $this->data["state"], PDO::PARAM_STR); 
       $st->bindValue(":postal_code", $this->data["postal_code"], PDO::PARAM_STR); 
       $st->bindValue(":country", $this->data["country"], PDO::PARAM_STR); 
       $st->bindValue(":hphone", $this->data["hphone"], PDO::PARAM_STR); 
       $st->bindValue(":wphone", $this->data["wphone"], PDO::PARAM_STR); 
       $st->bindValue(":mphone", $this->data["mphone"], PDO::PARAM_STR); 
       $st->bindValue(":emp_email", $this->data["emp_email"], PDO::PARAM_STR); 
       $st->bindValue(":gender", $this->data["gender"], PDO::PARAM_STR); 
       $st->bindValue(":DOB", $this->data["DOB"], PDO::PARAM_STR); 
       $st->bindValue(":ssn", $this->data["ssn"], PDO::PARAM_STR); 
       $st->bindValue(":ethnicity", $this->data["ethnicity"], PDO::PARAM_INT); 
       $st->bindValue(":filing_status", $this->data["filing_status"], PDO::PARAM_STR); 
       $st->bindValue(":emp_sdate", $this->data["emp_sdate"], PDO::PARAM_INT); 
       $st->bindValue(":fk_department", $this->data["fk_department"], PDO::PARAM_INT); 
       $st->bindValue(":job_title", $this->data["job_title"], PDO::PARAM_STR); 
       $st->bindValue(":fk_manager", $this->data["fk_manager"], PDO::PARAM_STR); 
       $st->bindValue(":drug_test", $this->data["drug_test"], PDO::PARAM_STR); 
       $st->bindValue(":bg_check", $this->data["bg_check"], PDO::PARAM_STR); 

       $st->execute(); 
       parent::disconnect($conn); 
      } catch (PDOException $e) { 
       parent::disconnect($conn); 
       die("Query failed: " . $e->getMessage()); 
      } 
      } 

내가 뭘 잘못하고 있는지 확실하지 않습니다. 누군가가 나를 도울 수 있기를 바랍니다.

답변

7

어디에도 :id_employee을 설정하지 않은 것 같습니다.

+0

대단히 감사합니다. 그것은 그것의 일부였습니다. 나도 철자가 틀렸어. – REF

+0

ds_employee_detail.filing_staus = : filing_status, filing_status 여야합니다. 그러나 제출할 때 모든 데이터가 지워 집니까? 어떤 생각? – REF

+0

나는 그것을 고쳤다. 개체를 전달할 때 isset이 누락되었습니다. – REF

관련 문제