[eluser]Fielder[/eluser]
My model runs this query
Code:
// ** MODEL **
function getBusinessbyName($request)
{
$this->db->where('bus_name',$request);
$results = $this->db->get('bus');
if ($results->num_rows() > 0)
{
return $results->result_array();
}
}
and it will return any number of rows.
However, within each of the rows returned, I only need the bus_id field from each row. So back in my controller I'm running
Code:
// ** CONTROLLER **
$results = $this->business->getBusinessbyName($bus_name);
foreach ($results as $row)
{
$bus_id[] = $row['bus_id'];
}
$query = $this->contract->getAllContractsbyBus($bus_id);
Then I want to pass that new $bus_id[] array into another model function called getAllContractsbyBus()
Code:
// ** MODEL **
function getAllContractsbyBus($bus_id)
{
$this->db->select('*');
$this->db->from('contract');
$this->db->join('bus','bus.bus_id = contract.bus_id','left');
$this->db->join('employees','employees.employee_rep = contract.employee_rep','left');
$this->db->where('bus_id',$row[]);
foreach ($bus_id as $row)
{
$this->db->where('bus_id',$row['bus_id']);
}
$results = $this->db->get();
if ($results->num_rows() > 0)
{
return $results->result_array();
}
}
but I don't think it's running the right way. Am I on the right track?
In fact, I want the WHERE clause to be OR instead of AND.