[eluser]mrliam69[/eluser]
I have created a for each loop to create my string.
Code:
$ValidDealersForUser = "SELECT DealerLogNumber
FROM `tblDealerInfo`
WHERE `DealerCode` = (
SELECT `UserDealerCode`
FROM `fa_user_profile`
WHERE id = ? )";
$VDFUquery = $this->db->query($ValidDealersForUser,$this->db_session->userdata('id'));
$MAX = $VDFUquery->num_rows();
$ValidDealers = "";
$i=1;
foreach ($VDFUquery->result_array() as $row)
{
$ValidDealers = $ValidDealers.$row['DealerLogNumber'];
if ($i==$MAX)
$ValidDealers=$ValidDealers;
else
$ValidDealers=$ValidDealers.",";
$i++;
}
this creates a string called
$ValidDealers which in my test echo returns 5,6
so db part now becomes
Code:
$this->db->where_in('VehServicingDealer',array(($ValidDealers)));
using the $ValidDealers in the array
but the sql generated is
SELECT * FROM (`tblVehicles`) WHERE `VehLog` = '3390' AND `VehServicingDealer` IN ('5,6')
which is incorrect as the end bit should be
IN (5,6) without the apostrophes?
How can I strip the apostrophes ?