We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How can I use some MySQL builtin function in PHQL

Hi there, I want check some string in DB in lower case.

For example I want to run this query in MySQL DB using PHQL :

SELECT *
FROM  Users
WHERE  LOWER(username)  = 'john'

I don't want to use raw query.

How can I do that?

Thanks

You can use normal SQL Statements. But then you kind of bind your project to mySQL. If thats no problem for you, you can use something like that:

//$anyModel is just a Model() object.
$result = new \Phalcon\Mvc\Model\Resultset\Simple(null, $anyModel, $anyModel->getReadConnection()->query('DESCRIBE _auth_users;'));

Your solution can't help me. I don't want to dependent my project to a specific databse.

I was think that ORM handle this problem.

Thanks for your reply.

You can use normal SQL Statements. But then you kind of bind your project to mySQL. If thats no problem for you, you can use something like that:

//$anyModel is just a Model() object.
$result = new \Phalcon\Mvc\Model\Resultset\Simple(null, $anyModel, $anyModel->getReadConnection()->query('DESCRIBE _auth_users;'));