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 to update column on where condition?

the method of save and update didn't like the find and findFirst which receive the condition parameter...

Please give more information.

edited Apr '14

example code:

$address = new Address();
$address->id = $id;
$address->userId = $userId;

i want the sql executed is UPDATE address SET xx=xx WHERE id=$id AND userId=$userId, but actually executed is UPDATE address SET xx=xx, userId=$userId WHERE id=$id... and i don't know how to pass the where condition to the update or save method...


The "where" condition is automatically determined by Phalcon, based on the primary key of the Address table. If you want userID to be included in the WHERE clause, you need to make it part of the primary key.

If you don't/cant do that, you'll have to resort to PHQL and building the query yourself.

edited Apr '14

oh, i see... thank you very much!

edited Apr '14

Hello, It seems that this question is similar to mine, so I will post it here. I have this function that doesn't work. It doesn't return any error, but it doesn't updates the record in database. Is there something wrong with phalcon update? I've tried also with other functions and it didn't work either.

public static function updateResponse($response,$sugester,$sugested,$location_id) {

$sql = "UPDATE Sugestion SET response=$response WHERE sugester=$sugester AND sugested=$sugested AND location_id=$location_id;";

$sugestion = new Sugestion();

return new Resultset(null, $sugestion, $sugestion->getReadConnection()->query($sql));


It's just making an update in a record. What ever I do, it just doesn't update. Thank you so much!


This question has been answered - if you're having a problem of your own, please start a new thread.