Debugging in Grocery CRUD

后端 未结 1 554
心在旅途
心在旅途 2021-01-24 15:04

How do i debug my callback scripts?

I have a deal_management function which does grocery CRUD

and i have a

callback_after_insert( array( $this,          


        
相关标签:
1条回答
  • 2021-01-24 15:41

    First of all ensure that call_user_func works properly with your function. So for example you can try this:

    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 in callbacks is that there is no error displaying when something goes wrong. So for example if you have

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

    test2 function does not exist. But there is no error anywhere.

    If everything goes fine with this, you can simply debug your insert/update with a simply hack.

    In grocery CRUD the insert/update/delete is an ajax call, so to debug your project, you have to debug it with the firefox firebug. You can have your var_dump or print_r and see the ajax call response from your firebug. If you are not familiar with how to use firebug, I have a little hacking solution for the debug.

    Simply go to your add or edit form and disable all the javascripts (You can download Web Developer for firefox and then click Disable>Disable Javascript>All Javascript). Then if you refresh the form add or edit and push submit, there will be the ajax request in a view. So there you can see your var_dump or print_r.

    Still grocery CRUD doesn't support debugging for callbacks so I think its a good solution for now. Beside this for debugging without hacking you can always easily have the log_message function of codeigniter. For more you can see at http://ellislab.com/codeigniter/user-guide/general/errors.html

    0 讨论(0)
提交回复
热议问题