title: SQLSTATE[HY000]: General error: 1366 Incorrect integer value:
body: <pre><code>$order = new Application_Model_DbTable_Order();
  
  $orderno = $order-&gt;select()
  -&gt;from($order, 'orderno')
  -&gt;where('memberid = ?', $userid)
  -&gt;order('orderno DESC')
  -&gt;limit(1, 0);
  </code></pre>
  
  <blockquote>
    <p>SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'SELECT <code>ordertable</code>.<code>orderno</code> FROM <code>ordertable</code> WHERE (memberid = '30') ORDER BY <code>orderno</code> DESC LIMIT 1' for column 'orderno' at row 1</p>
  </blockquote>
  
  <p>Got this error and am wondering if there is anything wrong with my code, because I have searched everywhere for the cause but don't seem to find any help.</p>
  
  <pre><code>#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`)
  </code></pre>
  
  <p>This is my sql code if it helps I'm using MySQL.</p>
  
  <pre><code>$request = new Zend_Session_Namespace('cart');
  
  $auth = Zend_Auth::getInstance();
  $user = $auth-&gt;getIdentity();
  $userid = $user-&gt;userid;
  
  $order = new Application_Model_DbTable_Order();
  $itemdb = new Application_Model_DbTable_Item();
  $orderdetail = new Application_Model_DbTable_Orderdetail();
  
  $data = array ('memberid' =&gt; $userid);
  $order-&gt;insert($data);
  
  $orderno = $order-&gt;select()
  -&gt;from($order, 'orderno')
  -&gt;where('memberid = ?', $userid)
  -&gt;order('orderno DESC')
  -&gt;limit(1, 0);
  
  
  foreach ($request-&gt;array as $var)
  {
  $unitprice = $itemdb-&gt;select()
  -&gt;from('$itemdb', 'unitcost')
  -&gt;where('itemid = ?', $var);
  
  $newArray = array('orderno' =&gt; $orderno,
  'itemid' =&gt; $var,
  'unitcost' =&gt; $unitprice, );
  
  $orderdetail-&gt;insert($newArray);                    
  }
  </code></pre>
  
  <p>Any guidance will be very much appreciated.</p>