$result3=$this->hrdb->select(array('concat(eb.first_name," ",eb.middle_name, " ",eb.last_name,"") as emp_name','eb.id','pp.emp_id','pp.gross_monthly','pp.amount as net_amount','pp.payslip_id','eor.dep_id'))
->where('pp.emp_id' not_in (select(array('pp.gross_monthly','pp.emp_id','pp.amount as net_amount','pp.payslip_id'))),Null,FALSE)
->from('payroll_payments as pp')
->join('employee_basic as eb','pp.emp_id=eb.id','left')
->join('employee_org as eor','pp.emp_id=eor.emp_id','left')
->order_by($_field, $params['_sort_direction'])
->where(array('pp.npyear'=>$params['nep_year'],'pp.npmonth'=>$params['nep_month2']))
->get()
->result();
是我写的查询,但问题出现了
解析错误:语法错误,意外的T_STRING /var/www/html/vianet_db/htdocs/addons/shared_addons/modules/hrm/models/payslip_m.php 在第558行
答案 0 :(得分:0)
使用concat(eb.first_name." ".eb.middle_name." ".eb.last_name."") as emp_name
并检查。从查询中删除'
引用,只需添加字段名称即可。而不是'eb.id','pp.emp_id'
,请使用eb.id,pp.emp_id
。对选择部分中的所有字段执行此操作,不需要数组ID。
答案 1 :(得分:0)
您需要在SELECT中添加第二个可选参数FALSE(也请先选择),以免自动转义字符。
$subqueryResult = //your subquery result in array
$result3=$this->hrdb->select(array('concat(eb.first_name," ",eb.middle_name, " ",eb.last_name,"") as emp_name','eb.id','pp.emp_id','pp.gross_monthly','pp.amount as net_amount','pp.payslip_id','eor.dep_id'), FALSE)
->from('payroll_payments as pp')
->join('employee_basic as eb','pp.emp_id=eb.id','left')
->join('employee_org as eor','pp.emp_id=eor.emp_id','left')
->where_not_in('pp.emp_id', $subqueryResult)
->where(array('pp.npyear'=>$params['nep_year'],'pp.npmonth'=>$params['nep_month2']))
->order_by($_field, $params['_sort_direction'])
->get()
->result();