⚠ 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

Debugging ADD and EDIT errors



dwdc

dwdc
  • profile picture
  • Member

Posted 01 March 2014 - 16:10 PM

I have setup a controller with a GC table and when I try to to add a row, it generates an error:

An error has occurred on insert

Then I tried to EDIT an existing row and got an error like the following:

An error has occurred on saving.


Now I am ecstatic that error messages are generated from GC, I am not sure why I am not able to do these simple actions.

I assume it has something to do with a mySQL error.

Can someone recommend how to get more data to display for me to allow me to DEBUG my script. i.e. ECHO mySQL string, etc...

Thanks!


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 02 March 2014 - 21:08 PM

Well a possible way to perform such debuging may be using the CI profiler

 

$this->output->enable_profiler(TRUE);

 

try and see if it can help you...

Else u are recommended to post in your code / table structure... so that in case there is error in code - some1 may help u fix it.


voghDev

voghDev
  • profile picture
  • Member

Posted 20 May 2014 - 11:31 AM

Well a possible way to perform such debuging may be using the CI profiler

 

$this->output->enable_profiler(TRUE);

 

try and see if it can help you...

Else u are recommended to post in your code / table structure... so that in case there is error in code - some1 may help u fix it.

 

this line goes where?

view? controller?


voghDev

voghDev
  • profile picture
  • Member

Posted 20 May 2014 - 12:09 PM

Tried Amish's solution with no luck :( i'm having the same error.

 

posted it on StackOverflow to not repeat the same thread in this forum:

 

 

http://stackoverflow.com/questions/23759240/grocery-crud-how-to-debug-add-edit-errors


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 20 May 2014 - 20:19 PM

well this wont solve yr problem but avail u information as to identify what and where is the error / problem. I will recommend the CI mode to be in developer mode rather then being production. With this, it will help u identify any sort of errors if at all available. And whatever errors if such dose get generated it will be printed out in the output / response. U might be able to view the same using firebug.

Hope this instructions help u reach to the root cause of your problem.. Else - do 1 thing share the tables ddl and the code of the controller .. and we might try and understand as where and what the error is .!


voghDev

voghDev
  • profile picture
  • Member

Posted 21 May 2014 - 11:24 AM

Good! i solved it! 

Gonna post a new thread with my solution and steps followed


voghDev

voghDev
  • profile picture
  • Member

Posted 21 May 2014 - 11:43 AM

@dwdc. in order to debug the SQL code, i suggest you this:

 

1. define a callback function after insert inside your controller:

 

            $crud->callback_after_insert(array($this, 'after_insert_callback'));

 

 

2. then, inside the callback function, display the last SQL query done against the DB:

 

 

     function 

after_insert_callback($post_array,$primary_key)

    {
            log_message('debug', 'SQL: '.$this->db->last_query());
    }

 

3. don't forget to enable logging output to be able to see it:

 

you need to set write permissions on the logs/ folder

 

    chmod a+w logs/

 

and also, inside /application/config/config.php, set:

 

    $config['log_threshold'] = 2;

 

to enable debug output

 

hope it helps!