1
這是payment_customer表的表結構。Magento自定義查詢插入數據到數據庫
CREATE TABLE IF NOT EXISTS `payment_customer` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`added_date` datetime NOT NULL,
`merchant_reference_no` varchar(20) NOT NULL,
`amount` int(10) NOT NULL,
`order_desc` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
上表存儲了有關付款客戶的數據。我使用下面的查詢將數據插入到我的自定義支付網關模塊中的表中。
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$sql = " INSERT INTO payment_customer ('id', 'added_date', 'merchant_reference_no', 'amount', 'order_desc') VALUES (NULL, '2013-02-13 00:00:00', '233AX23', '200', 'test'); ";
$write->query($sql);
然後我試圖
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$sql = " INSERT INTO sampath_payment_customer ('id', 'added_date', 'merchant_reference_no', 'amount', 'order_desc') VALUES (?, ?, ?, ?,?); ";
$write->query($sql, array('NULL', '2013-02-13 00:00:00', '233AX23', '200', 'test'));
$write->save();
但兩者不插入任何數據,而不是它給了我下面的錯誤消息。
我該如何解決這個問題?
檢查錯誤報告你收到了什麼錯誤? – Mufaddal 2013-02-12 05:34:07
這就是我得到的錯誤 – Techie 2013-02-12 05:38:34