in my own module I want to INSERT the orderId to my own DB Table.
$data = array( 'order_id' => $order->getId() );
$model = Mage::getModel('magic/test')->setData($data);
try {
$model->save();
Mage::getSingleton('adminhtml/session')->addSuccess('Success');
} catch (Exception $e){
Mage::getSingleton('adminhtml/session')->addError('Error'.$e->getMessage());
}
But I get this Exception:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE (order_id='8606')' at line 1, query was: UPDATE
magic_test
SET WHERE (order_id='8606')
my table Structure
CREATE TABLE IF NOT EXISTS `magic_test` ( `order_id` int(10) unsigned NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;`
ALTER TABLE `magic_test`
ADD PRIMARY KEY (`order_id`), ADD UNIQUE KEY `order_id` (`order_id`);
I want to insert data but why Magento makes a UPDATE SQL query?
I trying to delete some data with
$model = Mage::getModel('magic/test');
$model->setId('123456')->delete();
This works like a charm!
8606
in it. – Adarsh Khatri Jun 18 at 11:52