dan*_*oon 8 mysql zend-framework escaping prepared-statement
我正在尝试获取使用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));
Run Code Online (Sandbox Code Playgroud)
当我使用__toString()方法时$this->dbSelect,我得到了
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'))
Run Code Online (Sandbox Code Playgroud)
这只返回满足product_ref_id = 10条件的行.如何获得IN子句
product_ref_id IN ('10', '12')
Run Code Online (Sandbox Code Playgroud)
要么
product_ref_id IN (10, 12)
Run Code Online (Sandbox Code Playgroud)
使用Zend DB预处理语句,以便我可以获取产品id数组中包含的所有行?
ben*_*ben 16
不要内爆数组,只需传递它:
->where('product_ref_id IN (?)', $product_ids);
Run Code Online (Sandbox Code Playgroud)