我的表头中有一个锚标记,它调用一个控制器方法。我用过这个,
<th width="15%" align="center" class="grid_header">Category
<?=anchor('customer/basic/'.$keyword.'/Category/'.$this->customerlist->
fieldTest('dbCategory', $sort_field, $sort_order), 'Category')?></th>
我有这个方法,
function Basic($keyword = $this->input->post('keyword'),$sort_field = 'default_field',$sort_order = 'default_order')
{
//Using form input to determine what fields to search in the table with $keyword
$section = $this->input->post('section');
//Start prepping the query
foreach($section as $key => $tbl_field)
{
//For first field generate 'like' statement, the rest get 'or_like'
if($key == 0) {$this->db->like($tbl_field, $keyword); }
if($key > 0) { $this->db->or_like($tbl_field, $keyword); }
}
//Perform the query, and set the results as an array
$query = $this->db->get('tbl_customer');
$result = $query->result_array;
//Sort the Array
$result = $this->customerlist->orderBy($result, $sort_field, $sort_order);
$data['customerdata'] = (object)$result; //I like to work with objects in my views
print_r($data['customerdata']);
//Load the view with the sorted search results
$data['keyword']=$keyword; //
$data['sort_field']=$sort_field; // send these to the view for sorting links
$data['sort_order']=$sort_order; //
$this->load->view('customerdetails', $data);
}
我在行
中收到错误Parse error: syntax error, unexpected T_VARIABLE
function Basic($keyword = $this->input->post('keyword'),$sort_field =
'default_field',$sort_order = 'default_order')
任何建议......
修改 资料来源:http://codeigniter.com/forums/viewthread/112696/#571876
答案 0 :(得分:1)
参数中的默认值不能是变量。