I want to write a CodeIgniter active record query for the following raw SQL:
select *
from bookdetails
where editionId=$edid1
or editionId=$edid2
Below is my CodeIgniter attempt.
public function get_rare_outofprintBooks($edid1,$edid2)
{
$this->load->database();
$query = $this->db
->get_where(
'bookdetails',
array('edition_id' => $edid1),
array('edition_id' => $edid2)
); // I tried like this but its NOT Working
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;
}
$this->db->where('editionId', $edid1);
$this->db->or_where('editionId', $edid2);
It's right in the documentation http://ellislab.com/codeigniter/user-guide/database/active_record.html