Bug Report #4047

Returning if query was successful in UPDATE

Added by George Fekete over 3 years ago. Updated over 3 years ago.

Status:ClosedStart date:06/15/2011
Priority:NormalDue date:
Assignee:-% Done:


Target version:Kohana v3.x - v3.2.0
Resolution:invalid Points:


Currently the we get the number of affected rows on UPDATE queries.
It would be good if we would also get if the query itself was successful.

I want to update a row with the same data as in the database.
Although the query runs ok, the affected rows will remain 0 because nothing was updated.

We need a differentiation between affected rows and query successful.


#1 Updated by Vit Brunner over 3 years ago

If I see it right, you should get an exception on an unsuccesful query:
  • Kohana_Database_MySQL::query() throws Database_Exception when mysql_query returns false
  • Kohana_Database_PDO::query() rethrows PDOException from PDO::query()

In my opinion, it would be better to rethrow as Database_Exception in the second case (for consistency).

If that is done, Kohana_Database::query() should have this in PHPDoc:

@throws Database_Exception

#2 Updated by Jeremy Bush over 3 years ago

  • Status changed from New to Closed
  • Target version set to v3.2.0
  • Resolution set to invalid

Yeah, I'm not sure what you mean. An "unsuccessful" query (one that never hit the database) would result in a database exception.

In your scenario, the query was successful.

#3 Updated by Vit Brunner over 3 years ago

As for my previous comment, I didn't realize I was looking at early 3.0 branch. Kohana_Database_PDO::query() throws Database_Exception on 3.x/master. So please disregard my previous comment :)

Also available in: Atom PDF