作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试获取我使用 Zend Framework 1.11 的整数数组中的行。
$this->dbSelect
->from($table_prefix . 'product_link')
->joinLeft($table_prefix . 'product_link_name', $table_prefix . 'product_link.product_link_name_ref_id = ' . $table_prefix . 'product_link_name.product_link_name_id')
->where('product_ref_id IN (?)', implode(', ', $product_ids));
当我使用 $this->dbSelect
的 __toString()
方法时,我得到
SELECT `phc_distrib_product_link`.*,
`phc_distrib_product_link_name`.*
FROM `phc_distrib_product_link`
LEFT JOIN `phc_distrib_product_link_name`
ON phc_distrib_product_link.product_link_name_ref_id = phc_distrib_product_link_name.product_link_name_id
WHERE (product_ref_id IN ('10, 12'))
这只会返回满足 product_ref_id = 10 条件的行。我怎样才能让 IN 子句成为
product_ref_id IN ('10', '12')
或
product_ref_id IN (10, 12)
使用 Zend DB 准备好的语句,以便我可以获取产品 ID 数组中包含的所有行?
最佳答案
不要内爆数组,只是传递它:
->where('product_ref_id IN (?)', $product_ids);
关于mysql - 如何使用 Zend DB 做 MySQL IN 子句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8682520/
我是一名优秀的程序员,十分优秀!