I'm currently trying to write a query in codeigniter, I'm having a problem including and implode inside the query. This is my code.
$permitedCodeList = ["ELEC-22", "ELEC-100", "ELEC-200", "999873"];
$query = $this->inventario_db->query("
SELECT *
FROM pt_inv_num_id_equipo
WHERE numID = '123456789' AND codigo IN ('" . implode("','", $permitedCodeList). "')
LIMIT 1
");
$result = $query->row();
I'm getting the following error message: Unknown column 'ELEC' in 'where clause'. I know it has todo with the implode returning the data as ELEC-22,ELEC-100,ELEC-200,999873 but it doesn't seem to add a single quote to each value and include it in the query.
Any help is greatly appreciated.
codigovalues. Is there really nothing else to your code than what you've shown?