⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Display error message when updating database is failed



manushimn

manushimn
  • profile picture
  • Member

Posted 12 May 2014 - 20:54 PM

First of all this post is not about form validations (javascript), but validations with respect to the database constraints..

 

  • When I add data through the add form, there are some cases which the database will not update due to database constraints I have initialized when making the database (such as duplicating primary key).. In such cases grocery crud add form will not display any error. but just kept displaying the ajax loader image.
     
  • When I edit data through the edit form, there are some cases which the database will not update due to database constraints I have initialized when making the database (such as foreign key on update constraints).. In such cases grocery crud add form will not display any error. but just kept displaying the ajax loader image.
     
  • When I try to delete a record from grocery crud table, there are some cases which the database will not let delete that record due to database constraints I have initialized when making the database (such as foreign key on delete constraints).. In such cases grocery crud will not display any error and do nothing.

 

In the above mentioned cases how can we display errors? is there any built in function for that in grocery crud? else how can we implement? (But when a record is inserted/edited/deleted successfully, grocery crud will display the successful msg)

 

This is important, because else user will think database did not update due to our coding bugs

 


Dogtooth

Dogtooth
  • profile picture
  • Member

Posted 26 January 2015 - 20:44 PM

Really important post. Should get some attention...!


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 27 January 2015 - 07:32 AM

Hi there,

 

try to understand the phenomena of the library.. it is all being played up on Ajax calls .. the response expected is json. In case if the data that arrives in.. is not in the expected pattern .. what is going to happen? If the mode of the application is in development mode - and there are warnings that keeps on shooting in the call.. it wont form up to be a json code - rather it will be more of mixed junk. In this scenario - it will not be able to process the output.. and javascript here for that reason fails...!!

When js fails ... it dose not proceed further with rest of instructions to process... so you will either see that ajax loader keep on running.. or if the exception was handled properly.. it will just remove the ajax loader but wont proceed further with functionality.

 

If for other instance - the mode of codeigniter is in production mode .. and if any error occurs... it is not going to display any errors.. but rather kill  the process.. in that case too the response is null..!! and here - since the response is null / blank.. it wont again process further... and stand still but display no error..

 

Displaying error - yes is important ... it will be great if it gets managed accordingly.. But inspite of all.. still what i recommend - use up firefox with firebug addon .. for every failed request.. checkout the response for the request made to the server.. there if it displayes the error / warnings.. u know what to do.. or if it dose not display errors - turn the mode to development - see the errors coming in.. or check in the error log files...

 

We are to derive the solutions out of the box.. GC is a great library but no library are going to be complete - 100% spoon feeding library.. we all are developers.. we find anything in the library missing - fine.. get some time... update the library ... make if function as per our requirement. You are truely free to do the same.. i know Web Jhonny wont have any issue in regards with it :)

 

Else .. yes we have this wonderful forum around.. and you can go ahead - post it here.. some1 or the other might turn around and help .. .so can u.. if u have a solution .. someone is seeking...!! share it.. if u dont .. but u believe u can.. solve it for him / her..

 

Happy GCing :)


Dogtooth

Dogtooth
  • profile picture
  • Member

Posted 27 January 2015 - 11:47 AM

Well. Yes. But: The occuring error here is important for the end-user. It's not some code going wrong or other error which should not be visible in production mode, but a foreign key contraint, which HAS to be communicated to the user -somehow-.

 

It's about "You can't delete this person, because there is other stuff related to the person. You have to delete the other stuff first, if you really want to delete the person." This kind of message needs to be shown, in some way.

 

When I, as developer, use firebug, I can see the response from the database. But the user will only see - nothing. Is there any way to catch these kinds of errors, so you can produce a appropriate message for the user? There has to be, but I just have no idea where to start looking for a solution.