【发布时间】:2015-07-15 17:48:08
【问题描述】:
我一直试图在 codeigniter 中实现简单的 where 子句。我有的是这个
public function get_low_stock()
{
$this->db->select('*');
$this->db->where('productQty <=' , '10'); //line where the problem is
$this->db->from('products');
$query = $this->db->get();
return $query->result();
}
我需要从 minQty 列中选择值“10”,但无法实现。这样,一旦我更改了数据库中的 minQty,我就会自动获得正确的低数量。请看我的表结构。
CREATE TABLE IF NOT EXISTS `products` (
`productid` int(11) NOT NULL,
`productname` varchar(30) NOT NULL,
`catid` int(11) NOT NULL,
`productqty` int(11) NOT NULL,
`buyprice` int(11) NOT NULL,
`saleprice` int(11) NOT NULL,
`minqty` int(11) NOT NULL,
`maxqty` int(11) NOT NULL,
`alertlevel` int(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `products`
--
INSERT INTO `products` (`productid`, `productname`, `catid`, `productqty`, `buyprice`, `saleprice`, `minqty`, `maxqty`, `alertlevel`) VALUES
(1, '2.6 china touch', 1, 9, 2500, 5000, 10, 100, 15),
(4, '2.9 china touch', 1, 10, 2500, 5000, 10, 100, 15),
(5, '3.0 small cable', 1, 5, 2500, 5000, 10, 100, 15);
【问题讨论】:
标签: php mysql database codeigniter