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

Suppress SQLSTATE[HY000]: General error

I have a Raw SQL query I'm executing:

$winner = "55ee5c4e302cd";
$sql   = "UPDATE users,
          (SELECT * FROM
           phistbumps
           WHERE contest=$contestId AND image='$winner') winners
          SET users.levelProgress = users.levelProgress+20
          WHERE users.id=winners.user";
$notifications = new Notifications();
$notifications = new Resultset(null, $notifications, $notifications->getReadConnection()->query($sql));

The query works just fine, the values I want incremented in the DB are incremented, but it's echoing the SQLSTATE error, even when I don't specify for any output. Is there any way to suppress this error message?

I get no errors when I run this query through phpMyAdmin, so I believe the query is fine. I believe the issue is that no resulset is returned, what syntax will allow me to execute the query without expecting a return?



8.4k
Accepted
answer

Nevermind, just figured it out myself:

    $progress = new Users();
    $progress->getReadConnection()->query($sql);

Not sure which change fixed it, I first removed the unnecessary Resultset function, and I also made the model being used match the table that the query was being executed on.