Executing multiple queries in codeigniter that cannot be executed one by one
Maybe use transactions?
$this->db->trans_start();$this->db->query('AN SQL QUERY...');$this->db->query('ANOTHER QUERY...');$this->db->query('AND YET ANOTHER QUERY...');$this->db->trans_complete();
https://www.codeigniter.com/user_guide/database/transactions.html
Why not just write a stored procedure that does all the SQL you listed above taking the variables in your queries as parameters. Then just call the stored procedure as a single SQL statement;
$sql = "CALL some_sp($param1, $param2...etc)";
$query1 = $this->db->query("SELECT * FROM `Wo_Products` WHERE `boost_plan`=1 AND `tamatar`=1 AND`active`=1 ORDER BY rand() LIMIT 3");$query2 = $this->db->query("SELECT * FROM `Wo_Products` WHERE `boost_plan`=2 AND `tamatar`=1 AND`active`=1 ORDER BY rand() LIMIT 3");$query3 = $this->db->query("SELECT * FROM `Wo_Products` WHERE `boost_plan` NOT IN (0,1) AND `tamatar`=1 AND`active`=1 ORDER BY rand() LIMIT 6"); $result1 = $query1->result(); $result2 = $query2->result(); $result3 = $query3->result(); return array_merge($result1, $result2, $result3);