$order = new Application_Model_DbTable_Order();
$orderno = $order->select()
->from($order,'orderno')
->where('memberid = ?',$userid)
->order('orderno DESC')
->limit(1,0);
sqlSTATE[HY000]: General error: 1366 Incorrect integer value: ‘SELECT
ordertable
.orderno
FROMordertable
WHERE (memberid = ’30’) ORDER BYorderno
DESC LIMIT 1′ for column ‘orderno’ at row 1
得到了这个错误,我想知道我的代码是否有任何问题,因为我已经到处搜索原因,但似乎没有找到任何帮助.
#sql code for Ordertable#
`orderno` int(5) NOT NULL AUTO_INCREMENT,`memberid` int(5) DEFAULT NULL,PRIMARY KEY (`orderno`)
#sql code for Item#
`itemid` int(5) NOT NULL AUTO_INCREMENT,`image` varchar(100) NOT NULL,`itemname` varchar(30) DEFAULT NULL,`description` varchar(100) DEFAULT NULL,`itemtype` varchar(20) DEFAULT NULL,PRIMARY KEY (`itemid`)
#sql code for Orderdetail#
`orderdetailno` int(5) NOT NULL AUTO_INCREMENT,`orderno` int(5) NOT NULL,`itemid` int(5) NOT NULL,`unitcost` decimal(6,2) DEFAULT NULL,PRIMARY KEY (`orderdetailno`),KEY `orderno` (`orderno`),KEY `itemid` (`itemid`)
$request = new Zend_Session_Namespace('cart');
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
$userid = $user->userid;
$order = new Application_Model_DbTable_Order();
$itemdb = new Application_Model_DbTable_Item();
$orderdetail = new Application_Model_DbTable_Orderdetail();
$data = array ('memberid' => $userid);
$order->insert($data);
$orderno = $order->select()
->from($order,0);
foreach ($request->array as $var)
{
$unitprice = $itemdb->select()
->from('$itemdb','unitcost')
->where('itemid = ?',$var);
$newArray = array('orderno' => $orderno,'itemid' => $var,'unitcost' => $unitprice,);
$orderdetail->insert($newArray);
}
任何指导将非常感谢.
最佳答案
每https://stackoverflow.com/a/8882396/1432614,运行
SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;
如果要么包含STRICT_TRANS_TABLES,请将其从设置中删除.
例如:
SET @@GLOBAL.sql_mode= 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';