Vinod Jayachandran Tue May 29 09:11:14 -0400 2012

Subject: How to check the status of query execution

Hi ,

I am trying to do an insert.

Say

TableModel->save();

i want to know if insertion was success or did it throw any error (can be any reason say column doesn't exist or malformed url)
Does the TableModel->save(); return any value which i can capture to check the status of query execution ?


Megan McVey Wed May 30 15:36:00 -0400 2012

Model->save() returns true or false.

You can then use Model->errors to see the reasons why.

Sven Leuschner Mon Apr 08 08:30:39 -0400 2013

can you also get the number of affected rows ?

Alex J Mon Apr 08 13:45:41 -0400 2013

TableModel::rowCount()

or TableModel->rowCount() ?

Sven Leuschner Tue Apr 09 02:09:06 -0400 2013

??? .

that's obviously not the right thing

Let me explain: I have a user management page for the administrators in my web-application.
If an administrator only changes the user-rights, there's no change in the actual users table. But as a single function processes the user-management form, it does write the form-contents to the user-table.

Before I used mysqli and evaluated the return value of "affected Rows" to check if the update to the users table actually changed the user entry or not (affected Rows would be zero if nothing changed).
To "replicate" the behaviour of the function with PHP AR , I use
update_attributes(array)
And now I want to check again if the call to that method actually changed the user entry or not (to give appropriate response to the administrator ("No Changes to the User-Entry, the old password is still valid") <->("A new password has been activated, changes were successfully saved")

(1-4/4)