PHP-MySQLi-Database-Class icon indicating copy to clipboard operation
PHP-MySQLi-Database-Class copied to clipboard

ORs within WHERE AND clause easier?

Open palsypentertainment opened this issue 2 months ago • 0 comments

The following was my initial code:

$this->db->where( 'f.pendinglive', 1 );
$this->db->orWhere( 'f.statusshort', $status, 'IN' );

but now, I had to do the following to add an extra AND for f.date, as I'm not sure if the extra AND would have any diverse effects if adding it to the above:

$statusList = "'" . implode("','", $status) . "'";
$this->db->where( '( f.pendinglive = 1 OR f.statusshort IN ('.$statusList.') )' );
$this->db->where( "f.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 3 HOUR)" );

I just wanted to know if there's a way to nest an OR within a WHERE AND clause...... If not, it's fine, manually imploding arrays is just an extra step.

TIA.

palsypentertainment avatar Nov 16 '25 02:11 palsypentertainment