$builder = $this
->modelsManager
->createBuilder()
->from(Notice::class)
->where("notice_category_id = $id")
->orderBy("id desc");
then error message shows like this :
Column 'ice_category_id' doesn't belong to any of the selected models.....
notice's 'not'is gone...combine where not ice_category_id
is this a bug ,or I used QueryBuilder by wrong way?
phalcon version is 4.0.4
Please see the https://github.com/phalcon/cphalcon/issues/14918
You should use the PHQL escaping to fix your issue (and placeholders to avoid the SQL Injection) :
->where('[notice_category_id] = :id:', ['id' => $id]) ;
P.S. I always recommend to use the PHQL escaping
@TimurFlush
ok.I see.Thanks for your answer.
I'm happy to see someone did open a ticket already. I can confirm this bug, and also the woraround to fix it (use the escapers []). While escapers are recommended, but not required, this should be considered a bug.
I'm using Phalcon 4.0.6
It seems the problem is in PHQL parser, in \Phalcon\Mvc\Model\Query\Lang::parsePHQL(), therefore in internal phql_parse_phql(), and... C is not my land... At least for now :smile:
Quickest way to reproduce the bug:

I also got this error by naming a column "notes".
Duplicate issue: https://github.com/phalcon/cphalcon/issues/14641
Most helpful comment
@TimurFlush
ok.I see.Thanks for your answer.