2015-11-22 2 views
0

Даже после того, как прочитал все вопросы, связанные с PDO Insert not working, на S.O, я до сих пор не могу понять, что не работает в PDO SQL Query. Хотелось бы помочь в этом.PDO insert not working bindParam bindValue

$sql = "INSERT INTO `order_item` (`fk_order`,`fk_product`,`product_excl_tax`,`tax_product`,`shipping_excl_tax`,`tax_shipping`,`order_item_status`,`updated_at`) 
VALUES (:theorderid, :product_id, :product_price, :price_incl_tax, :product_shipping, :product_shippingttc, :order_item_status, :dater) " ; 

$req = $co_db->prepare($sql); 
$req -> bindParam(':theorderid', $theorderid, PDO::PARAM_INT); 
$req -> bindParam(':product_id', $product_id, PDO::PARAM_INT); 
$req -> bindParam(':product_price', $product_price, PDO::PARAM_STR); 
$req -> bindParam(':price_incl_tax', $price_incl_tax, PDO::PARAM_STR); 
$req -> bindParam(':product_shipping', $product_shipping, PDO::PARAM_STR); 
$req -> bindParam(':product_shippingttc', $product_shippingttc, PDO::PARAM_STR); 
$req -> bindParam(':order_item_status', $thestatus , PDO::PARAM_INT); 
$req -> bindParam(':dater', $thedate, PDO::PARAM_STR); 
$req->execute();  
+2

http://php.net/manual/en/function.error-reporting.php и http://php.net/manual/en/pdo.error-handling.php –

+0

У вас есть ошибки? – Mihai

+0

none ... Я пробовал все, но не смог найти – justberare

ответ

1

Благодаря @RyanVincent я добавил следующие строки в моем PDO подключения объекта декларации:

$ co_db-> SetAttribute (PDO :: ATTR_ERRMODE, PDO :: ERRMODE_EXCEPTION); $ co_db-> setAttribute (PDO :: ATTR_EMULATE_PREPARES, true);

Это позволило мне увидеть ошибку между данными, которые я хотел ввести, и ограничениями, установленными в MYSQL.