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

PHQL not support ORDER BY term in DELETE ?

I use PHQL in my project, I got an error.Here is my code:


<?php

$query = 'DELETE FROM Cars WHERE price < 50000 ORDER BY id ASC LIMIT 100';
$modelsManager->executeQuery($query);

It does not work in Phalcon V1.2.6 in windows.But I test the native SQL statement in phpmyadmin,it works.why?



58.4k

Hi I don't think it necessary when use SQL delete above

$query = 'DELETE FROM Cars WHERE price < 50000 ';


4.3k

how do you delete the last 100 records in database.

The latest Phalcon version is 1.3.1 - you should update to that and try again. I don't know for sure if it will fix the problem, but 1.3.0 had TONS of updates, and it's always best to try the latest version of software when you have problems like this.

If you do all that' and it still doesn't work, then I'd ask what "doesn't work" actually means? Does the query not get sent to your DB? Does Phalcon throw an exception? Do all "Cars" get deleted? Do no "Cars" get deleted?