我上周发现了非常好的php api,Grocery Crud,来自这里的例子http://www.grocerycrud.com/examples/the-simplest-example,我可以创建视图并且它工作正常,我的问题是有一个你编辑 Update Changes 和 Update Back to List 有2个按钮,我有兴趣打印post array每当我点击这两个按钮,这样我就可以看到内部数组是什么,而我的实际计划是每当我更新记录时(点击更新更改或更新并返回编辑中的列表),我需要更新约7个表
这是我到目前为止所尝试的,这里功能测试什么都没打印
function test($post_array)
{
echo "<pre>";
print_r($post_array);
echo "</pre>";
}
function myapp(){
$this->db = $this->load->database('Groupdb',true);
$crud = new grocery_CRUD();
$crud->set_table('main_table');
$crud->columns(
"Serial",
"Date",
"Time"
);
$crud->fields(
"Serial",
"Date",
"Time"
);
$crud->callback_after_update(array($this, 'test'));
$crud->set_subject('Update Mains');
$output = $crud->render();
$this->_example_output($output);
}
从我的代码我想你们可以想象表名是 main_table ,每当我更新main_table的序列号,日期和时间时,它必须反映在其他7个字段为日期和时间的表中,此处序列号是唯一的
2 回答
首先,如果您使用PHP> = 5.3,那么最好使用匿名函数,以确保它能够正常工作 . 例如,在您的代码中,您可以:
你已经注意到我确实在那里增加了一条线 . 这是
die();
. 通过这种方式,您可以确保在萤火虫上看到预期的结果 .可能你没有任何印刷品,因为杂货店CRUD正在删除之前用一些魔术代码打印的任何东西 . 使用
die();
,您只需确保永远不会达到此魔法代码 .这个问题已在以下网址得到解答:Debugging in Grocery CRUD
进一步来说: