I have a table in my database :
subscription_notification
id | subscription_id | notification_id | created
nothing special in the model, just a columnMap for camelCase :
public function columnMap()
{
return [
'id' => 'id',
'subscription_period_id' => 'subscriptionPeriodId',
'notification_id' => 'notificationId',
'created' => 'created'
];
}
When I want to do a simple count :
SubscriptionNotification::count(
[
"subscriptionPeriodId = ?0 and notificationId = ?1",
ApplicationEnum::BIND => [1, 1],
]
);
I get an error :
[Phalcon\Mvc\Model\Exception] Column 'ificationId' doesn't belong to any of the selected models (1), when preparing: SELECT COUNT(*) AS rowcount FROM [Models\SubscriptionNotification] WHERE subscriptionPeriodId = ?0 and notificationId = ?1
Same happens with the queryBuilder
$queryBuilder = $this->modelsManager->createBuilder();
$queryBuilder
->from(SubscriptionNotification::class)
->columns(['id'])
->where("subscriptionPeriodId = ?0", [$this->subscriptionPeriod->getId()])
->andWhere("notificationId = ?0", [$notificationId]);
echo $queryBuilder->getQuery()->getSql(); die;
I'm feeling like there is a bad escaping and the 'not' in notificationId is considered as a mysql key word. It works if I put brackets around my column name. But isn't it a bug after all ? It's new since I made (yesterday) Phalcon v4.0 migration, I noticed it in my unit tests.
Thank you for guiding me to the best solution