flightphp / core

An extensible micro-framework for PHP
https://docs.flightphp.com
MIT License
2.62k stars 409 forks source link

prefix bug into rawQuery #449

Closed ang3lx closed 7 months ago

ang3lx commented 3 years ago

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?

paxperscientiam commented 1 year ago

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