core icon indicating copy to clipboard operation
core copied to clipboard

prefix bug into rawQuery

Open ang3lx opened this issue 4 years ago • 1 comments

Hello I'm using prefix with my tables, and i've some problems with rawQuery

with this rawQuery

$db->rawQuery("SELECT COUNT(p.id_product) count 
FROM product p 
LEFT JOIN product_lang pl on pl.id_product=p.id_product WHERE `pl.id_lang` = ?",  array(1));

produce this output (with error 500). And table name and fields name are replaced with prefix, but in this case only table should be replaced.

Unknown column 'p.id_**ec_**product' in 'field list' query: SELECT COUNT(p.id_ec_product) count FROM ec_product p LEFT JOIN ec_product_lang pl on pl.id_ec_product=p.id_ec_product WHERE pl.id_lang = ? (1054)

insted if i use this rawQuery (with `)

$db->rawQuery("SELECT COUNT(p.id_product) count 
FROM `product` p 
LEFT JOIN `product_lang` pl on `pl.id_product`=`p.id_product` WHERE `pl.id_lang` = ?", array(1));

no replace are affected, and output is SELECT COUNT(p.id_product) count FROM product p LEFT JOIN product_lang pl on pl.id_product=p.id_product WHERE pl.id_lang = 1

how we should approach with this rawQuery?

ang3lx avatar Jul 21 '21 11:07 ang3lx

In case you're still wondering, you've posted to the wrong project :)

paxperscientiam avatar Sep 18 '22 16:09 paxperscientiam