How to find whether the database operation was successful?

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mdfaisalpapa
User
Posts: 84

How to find whether the database operation was successful?

Post by mdfaisalpapa »

i want to hide some fields while the user is in add,edit,gridadd,gridedit. hence i am using CurrentPage()->CurrentAction to identify the page and hide the fields. The issue is that in case there is some error at the database side the user is still in the add/edit mode but the

CurrentPage()->CurrentAction changes to insert,update,gridinsert,gridupdate and the fileds which are supposed to be hidden are available to the user.

incase i add insert,update,gridinsert,gridupdate to the condition to hide the fields. the fields are still hidden if the database operation is successful

ie CurrentPage()->CurrentAction changes to insert,update,gridinsert,gridupdate irrespective of success/failure at the database end.

is there anyway through which i can identify whether the database operation is success or failure so that i can hide the fields on add,edit,gridadd,gridedit and database error


mdfaisalpapa
User
Posts: 84

Post by mdfaisalpapa »

i have tried using CurrentPage()->getFailureMessage() in the Page_Load() , CurrentPage()->getFailureMessage() returns an empty string even on failure of the database operation.but the database oeration failes with the error message displayed is Failed to execute SQL. Error: Duplicate entry '1-18' for key 'idxCourseTrainee' and CurrentPage()->getFailureMessage() still has empty string


Webmaster
User
Posts: 9429

Post by Webmaster »

Check Conn()->ErrorMsg().


mdfaisalpapa
User
Posts: 84

Post by mdfaisalpapa »

Conn()->ErrorMsg() is also giving a blank string. May be since after the sql error many other sql queries are executed.

I am detecting SQL ERROR using the following in Message_Showing event.

$pos = strpos($msg, "Failed to execute SQL");// Detecting SQL ERROR
if($pos !== false)
{
//do things you want to do if there is a sql error
}


Post Reply