Hi,
I noticed while writing code for graceful handling of database error (such as foreign key violations) that it seems that insert and delete errors are caught by grocery CRUD, but not all update errors.
If I look at the library code, I notice the following:
For insert and delete, the actual query result is returned from the model to the library and stored in a variable:
line 775: $insert_result = $this->basic_model->db_insert($insert_data);
line 1007: $delete_result = $this->basic_model->db_delete($primary_key);
if $insert_result or $delete_result are false, the library function then returns false a few lines below and the error is eventually caught in the insert_layout or delete_layout functions.
For update, however, the library code is:
line 885: $this->basic_model->db_update($update_data, $primary_key);
So, the actual query result is not stored in a variable nor returned and any potential error will not be caught by the update_layout function.
Is this omission a bug or is there a purpose to this difference?
Thanks!
Query update errors not caught by grocery CRUD?
Started by lherlaar, 20 May 2012 - 11:59 AM
- Single Page
Posted 20 May 2012 - 11:59 AM
Posted 21 May 2012 - 07:09 AM
It is not on purpose I just forgot it! Thanks to mention that ( https://github.com/scoumbourdis/grocery-crud/commit/d4fd94dcbd090b8388ba9f3ee936a3c3c84f1529 )