CodeIgniter Forums
Can someone help me to edit this function to codeigniter 4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Can someone help me to edit this function to codeigniter 4 (/showthread.php?tid=86836)



Can someone help me to edit this function to codeigniter 4 - startup - 02-20-2023

PHP Code:
Please help me edit this function to codeigniter 4
public function makeQuery($minimum_price$maximum_price$brand$ram$storage){
 
$query "SELECT * FROM product WHERE product_status = '1' ";
 if(isset(
$minimum_price$maximum_price) && !empty($minimum_price) && !empty($maximum_price))
 {
 
$query .= "AND product_price BETWEEN '".$_POST["minimum_price"]."' AND '".$_POST["maximum_price"]."'";
 }
 if(isset(
$brand))
 {
 
$brand_filter implode("','"$brand);
 
$query .= "AND product_brand IN('".$brand_filter."')";
 }
 if(isset(
$ram))
 {
 
$ram_filter implode("','"$ram);
 
$query .= "AND product_ram IN('".$ram_filter."')";
 }
 if(isset(
$storage))
 {
 
$storage_filter implode("','"$storage);
 
$query .= "AND product_storage IN('".$storage_filter."')";
 }
 return 
$query;
    

thank you in advance


RE: Can someone help me to edit this function to codeigniter 4 - InsiteFX - 02-20-2023

Please read:

CodeIgniter 4 Users Guide -> Working With Databases -> Query Builder Class