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 NOT BETWEEN in a query in Phalcon? HELPME PLEASE

I am making a query using NOT BETWEEN using Phalcon Query Language (PHQL), but it is not working the application hangs. Someone could give me an idea of ​​how I could do it. Thank you very much. There is my query.

$sql = "SELECT c.* FROM table as c WHERE c.activated NOT BETWEEN :f1: and :f2: ";

    $parameters['f1'] = '2017-10-01';
    $parameters['f2'] = '2017-10-05';
    $result= $this->modelsManager->executeQuery($sql, $parameters);

every time the query is run this leaves:

Warning: session_destroy(): Trying to destroy uninitialized session in C:\xampp\htdocs\myapp\app\plugins\SecurityPlugin.php on line 222

shouldn't that query be something like ...WHERE not exists c.activated AND c.activated NOT BETWEEN ...

Best debugging I do with those is echo out the $SQL and take to your mysql gui and try it out

The warning message has nothing to do with the query, it says that the app is trying to close the session, but it was never started to begin with

edited Oct '17

I just had to put the NOT forward, I did not imagine, but there is an excellent explanation for that HERE:

https://stackoverflow.com/questions/46595626/how-can-i-use-not-between-in-a-query-in-phalcon/46596373#46596373