Debugging in food CRUD

How to debug my callback scripts?

I have a deal_management function that makes grocery CRUD

and i have

callback_after_insert( array( $this, 'insert_coupon_codes' ) ); 

since inserting in the database does not work in my insert_coupon_codes function I have no way to find out or view my SQL.

Is there any function with which I can debug my php scripts inside the callback function without any hacks?

I did print_r() and var_dump() , but they don't seem to work inside the callback function.

+1
source share
1 answer

First of all, make sure that the call_user_func function works correctly with your function. So, for example, you can try the following:

 function just_a_test() { call_user_func(array($this,'insert_coupon_codes')); } function insert_coupon_codes($post_array = array(), $primary_key = null) { echo "Just a test"; die(); //Your code here } 

The problem with callbacks is that something doesn't happen when displaying errors. For example, if you have

 call_user_func(array($this,'test2')); 

The function test2 does not exist. But there is no mistake.

If all goes well with this, you can simply debug your insert / update with a simple hack.

In grocery CRUD, inserting / updating / deleting is an ajax call, so you must debug it using firefox firefox to debug your project. You can get your var_dump or print_r and see the response to the ajax call from your firebug. If you are not familiar with how to use firebug, I have a small hacking solution for debugging.

Just go to the add or edit form and disable all javascripts (you can download the web developer for firefox, and then click Disable> Disable JavaScript> All Javascript). Then, if you update the form, add or edit, and click submit, the ajax request will appear in the view. So you can see your var_dump or print_r.

Another CRUD product does not support debugging for callbacks, so I consider it a good solution at the moment. In addition, for debugging without hacking, you can always easily use the log_message function for codeigniter. You can see more details at http://ellislab.com/codeigniter/user-guide/general/errors.html

+5
source

Source: https://habr.com/ru/post/1386031/


All Articles