我正面临一个问题,我的参数没有作为一个id传递它作为一个字符串并给我一个错误。 myhelper_helper.php
function get_branch($branch)
{
$CI = &get_instance();
$query = $CI->db->query(“select * from branches where branch_id = $branch”)->row();
$return = $query->branch_name;
return $return;
}
public function get_users_datatable()
{
$this->datatables->select(‘admin.admin_id,name,email,sex,birthday,religion,designation,address,phone,group_name,admin.branch_id,admin.user_id’)
->unset_column(‘admin.branch_id’)
->add_column(‘Branch’,get_branch(‘$1′),’admin.branch_id’)
->from(‘admin’)
->join(‘groups’,'groups.group_id=admin.group_id’,'left’)
->where(array(‘admin.group_id !=’=>0));
echo $this->datatables->generate();
//echo $this->db->last_query();
}
错误是
Error Number: 1054Unknown column ‘$1′ in ‘where clause’select * from admin where admin_id
= $1Filename: D:\xamp\htdocs\dnspak\vivid\system\database\DB_driver.phpLine Number: 331
答案 0 :(得分:0)
在你的助手中正在进行创建实例并运行sql查询,但是你没有使用codeigniter从数据库中获取值。
function get_branch($branch)
{
$CI = &get_instance();
$query = $CI->db->query(“select * from branches where branch_id = $branch”);
$result = $query->row();
$return = $result->branch_name;
return $return;
}
如果您喜欢上述代码,那么您将获得记录。