I'm new to PDO. I am checking for error conditions with a particular prepared statement and the only error information that's coming back is "HY093" with no textual assistance. I've googled around and from what I can tell, it appears to be caused by a problem binding parameters due to a type difference or something.
$insertCarImageSQL = 'INSERT INTO car_images (img_id, vid, src, thumb, is_default) VALUES (NULL, :vid, :src, \'\', :isdefault)';
$insertCarArray = array(
':vid' => $pendingImg['vid'],
':src' => $finalImagePath,
':isdefault' => $pendingImg['is_default']
);
$stmt = $this->db->prepare($insertCarImageSQL, $insertCarArray); // should throw an exception if it fails?? TODO: test if it does
$r = $stmt->execute();
if (!$r){
$errMsg = " INSERT car_images FAILED: \n" . $insertCarImageSQL . "\n" . print_r($insertCarArray, TRUE) . "\n" . $stmt->errorCode() . ':' . print_r($stmt->errorInfo(), TRUE);
throw new Exception($errMsg);
}
The $insertCarArray var looks like this:
Array
(
[:vid] => 191922
[:src] => 96___191922___wb3831-4.jpg
[:isdefault] => 0
)
The exception outputs roughly the following:
INSERT car_images FAILED:
INSERT INTO car_images (img_id, vid, src, thumb, is_default) VALUES (NULL, :vid, :src, '', :isdefault)
Array
(
[:vid] => 191922
[:src] => 96___191922___wb3831-4.jpg
[:isdefault] => 0
)
HY093:Array
(
[0] => HY093
[1] =>
[2] =>
)
Anyone know how I might fix this? I'm going to try casting my vars when I put them into the array first.