PHQL is not working and showing 404 error

Hello friends, I am tryong to get result from my database and I want to shoq it random and order by id but it is showing me 404 error page. What should I do not?

Here is my controller function

    $hpage = "SELECT * FROM `hpage` ORDER BY `id` DESC";      
    $this->view->hpagejobs = $this->modelsManager->executeQuery($hpage);

It is not working, and I tried this which is also not working

    $hpage = "SELECT * FROM `hpage` ORDER BY `RANDOM ()";     
    $this->view->hpagejobs = $this->modelsManager->executeQuery($hpage);

Its working only when I do this

    $hpage = "SELECT * FROM `hpage`";     
    $this->view->hpagejobs = $this->modelsManager->executeQuery($hpage);

Then it is working so can anyone tell me what is wrong with query?

edited Nov '14

PHQL never coused the routing/dispatching error like 404 error!!! It should be another problem.

In the other hand as I see in your PHQL queries for example:

SELECT * FROM `hpage` ORDER BY `id` DESC

You've used db table name (hpage) whereas in PHQL you should use models name with it's name space. For example if your "hpage" table mapped to "Hpage" model you shoud changed your query to:

SELECT * FROM Hpage ORDER BY `id` DESC

And if your model is in namespace for example App\Model you shoud change your query to:

SELECT * FROM App\Model\Hpage ORDER BY `id` DESC


84.5k

In PHQL you have to use PHQL's delimiters and not the MySQL ones, also you have to use classes instead of tables and attributes instead of columns. Check the documentation for an explanation: http://docs.phalconphp.com/en/latest/reference/phql.html#usage-example