Hi,
How can I use MySQL variables in a query?
If I try the variable inside a where clause, i.e:
UserModel::findFirst([
'company_id = @COMPANY_ID AND username = :username:',
'bind' => [
'username' => $username,
]
]);
I get a scanning error: Scanning error before 'COMPANY_ID AND u...'
.
When I use
new \Phalcon\Db\RawValue('@COMPANY_ID')
it still gets quoted in the query, while stated in the documentation: raw value without quoting or formatting.
Query log:
734 Query SELECT `user`.`user_id`, `user`.`company_id`, `user`.`username` FROM `user` WHERE `user`.`company_id` = '@COMPANY_ID' AND `user`.`username` = 'faim' LIMIT 1
Looking forward to a reply :-)