PHQL update

Hi,

I have some problems when using PHQL, do you have any idea? FYI, I do not use any Constraints in both MySQL and Phalcon.

thanks in advance

<?php

$query = 'UPDATE Table SET column = "value" WHERE id IN (1,2,3,4,5)'; // work
$query = 'UPDATE Table SET column = "value" WHERE id > 0';            // nothing happen in database
$query = 'UPDATE Table SET column = "value" WHERE 1';                 // nothing happen in database
$query = 'UPDATE Table SET id = 100 WHERE id = 101';                  // nothing happen in database
$query = 'UPDATE Table SET column = "value" WHERE id IN (1,2,3,4,5) ORDER BY id'; // error: "Syntax error, unexpected token ORDER, near to ' BY id', when parsing: UPDATE Table SET column = "value" WHERE id IN (1,2,3,4,5) ORDER BY id"
$this->modelsManager->executeQuery($query);

update:

I do more tests, and the result is showing that if I'm updating more than 7 rows it will not work.


update:

I still haven't found the solution to make PHQL works in this particular case. I tried raw SQL with the way provided by Andrey at https://forum.phalconphp.com/discussion/734/update-table-in-raw-sql-returning-value-on-success, now it works. More info, if update with the way described in doc: https://docs.phalconphp.com/en/latest/reference/phql.html#using-raw-sql, it will give "SQLSTATE[HY000]: General error" error.



831

is the model for Table already created ?



12.9k

Hi xicond,

Thanks for your reply, I truly appreciate it. Yes the corresponding model is created and working fine.

is the model for Table already created ?



831

need to investigate the model Table I think the "Syntax error, unexpected token ORDER" is already right



12.9k

Do you mean my model file cause the problem?

need to investigate the model Table I think the "Syntax error, unexpected token ORDER" is already right



831

Maybe, cause sometimes it bugs my code



12.9k

Actually it is possible, I did look at the model file and it looks ok to me.

Maybe, cause sometimes it bugs my code