PHP-MySQLi-Database-Class icon indicating copy to clipboard operation
PHP-MySQLi-Database-Class copied to clipboard

Can I use $db->func with select query and where condition

Open adildils opened this issue 6 years ago • 2 comments

Hi, Am i able to use $db->func with select query? $cols = Array ("emplyee_idno", "employee_name", "employee_rank","employee_dept",{$this->db->func('hex(employee_uid'))}); $employees = $this->db->get("employees",null,$cols);

Getting error for select query

Notice: Array to string conversion

Getting error for where condition

$this->db->where("employee_uid",$this->db->func("unhex($empid)));

Warning: mysqli_stmt::bind_param(): Invalid type or no types specified in MysqliDb.php on line 1588

When I echo query SELECT emplyee_idno, employee_name, employee_rank, employee_dept, '.Array.' FROM employees

adildils avatar Sep 22 '19 07:09 adildils

Hey @adildils , did you manage to work around this somehow? I'm hitting the same problem.

killua-eu avatar Oct 24 '21 07:10 killua-eu

func() should be used in insert or update statements. In where and get() you can specify functions as a string

$cols = Array ("hex(emplyee_idno) as employee_uid ", "employee_name", "employee_rank","employee_dept",$employees = $this->db->get("employees",null,$cols);

avbdr avatar Oct 24 '21 12:10 avbdr