Welcome Guest, Not a member yet? Register   Sign In
Adding Data to a MultiDimensional Array...
#4

The SQL statement you are looking for is IN. This function will match field with any value from comma separated array, so your SQL would look something like this:

Code:
SELECT y.CarID, y.Year FROM Years y WHERE y.CarID IN (123, 654, 789);

In CodeIgniter, there are handy way to implement this functionality with query builder:

PHP Code:
// check that we have any cars to match against first
if ($carIDs) {
    
$query $this->db
        
->select('CarID, Year')
 
       ->where_in('CarID'$carIDs)
 
       ->get('Years');
 
   print_r($query->result());

Reply


Messages In This Thread
RE: Adding Data to a MultiDimensional Array... - by Pertti - 07-17-2018, 11:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB