2014-09-26 4 views
1

매개 변수를 내 쿼리에 바인딩하려고하는데 일부 매개 변수를 바인딩하지 않습니다.pdo 매개 변수가 바인딩되지 않았습니다.

배치하는 배열

Array 
(
    [action] => add_category 
    [fk_user_account_type_id] => Array 
     (
      [0] => 1 
      [1] => 2 
      [2] => 5 
      [3] => 6 
      [4] => 7 
      [5] => 8 
      [6] => 9 
     ) 

    [cat_name] => Special Deals 
    [parent_cat] => 0 
    [cat_status] => Active 
    [page_content] => 

this is test 
) 

$cat_name = $postArray['cat_name']; 
$cat_status = $postArray['cat_status']; 
$parent_id = $postArray['parent_cat']; 
$cat_description = $postArray['page_content']; 

$sql = "INSERT INTO tbl_category SET `category_title` = :cat_name , `category_alias` = :category_alias , `category_status`= :cat_status, `category_parent_id` = :parent_id, " 
       . "category_description = :cat_description"; 
     $statement = $this->db->conn_id->prepare($sql); 
     $statement->bindParam(':cat_name', $cat_name, PDO::PARAM_STR); 
     $statement->bindParam(':cat_status', $cat_status, PDO::PARAM_STR); 
     $statement->bindParam(':category_alias', $category_alias, PDO::PARAM_STR); 
     $statement->bindParam(':parent_id', $parent_id, PDO::PARAM_INT); 
     $statement->bindParam(':cat_description',$cat_description, PDO::PARAM_STR); 

하고 난

echo $this->parms($sql,$postArray); exit // for debugging; 

을 수행 할 때이 값이 필요하고 그래서 그것은 나에게 참조로

INSERT INTO tbl_category SET `category_title` = 'Special Deals' , `category_alias` = 'special_deals' , `category_status`= 'Active', `category_parent_id` = :parent_id, category_description = :cat_description 
+0

은'UPDATE'가 아닌'INSERT INTO' –

+0

추가'의 setAttribute (PDO :: ATTR_ERRMODE는 PDO :: ERRMODE_EXCEPTION) 접속 후 '좋아, 열립니다. 구문 오류를 신호해야합니다. –

+0

@ Fred-ii- 아니요,'INSERT INTO'를 원하고'setAttribute (PDO :: ATTR_ERRMODE, PDO :: ERRMODE_EXCEPTION)'도 아무 것도 보여주지 않았습니다 – baig772

답변

0

BindParam 패스 같은 쿼리를 보여줍니다 없음, bindValue으로 바꿉니다. 당신이 아직 시도하지 않는 경우 당신이 원하는

$statement->bindValue(':cat_name', $cat_name, PDO::PARAM_STR); 
    $statement->bindValue(':cat_status', $cat_status, PDO::PARAM_STR); 
    $statement->bindValue(':category_alias', $category_alias, PDO::PARAM_STR); 
    $statement->bindValue(':parent_id', $parent_id, PDO::PARAM_INT); 
    $statement->bindValue(':cat_description',$cat_description, PDO::PARAM_STR); 
관련 문제