phql does not support the tablename as a "variable"

select * from (SELECT * FROM \Models\UserModel LIMIT 20) as tb

it will be an error

If i use the "count" function, that means , i select all the rows. How To Slove This Problem?

What error ?

Im guessing PHQL doesn't support subqueries like this. It's only supporting subqueries which will return only one column and only in select statements or where conditions. In from i guess it's not gonan work.

What you want to achieve ?



248
edited Apr '16

Uncaught exception 'Phalcon\Mvc\Model\Exception' with message 'Syntax error, unexpected token (, near to 'SELECT * FROM \Models\UserModel as u , \Models\NewsModel as n WHERE n.id = u.uid LIMIT 20) as tb ' As If I have a select statement that contain 2 tables , and i want to count the total rows , how can i do by phql?

SELECT *,(SELECT COUNT(Models\UserModel.id) FROM Models\UserModel) as count FROM \Models\UserModel LIMIT 20