Search query [multiple where condition in a tiny code]

codeigniter search query [multiple where condition in a tiny code] *return single row
in controller:
$wc=array(
         ‘table_field1’  =>  $where_value,
         ‘table_field2’  =>  $where_value
); //whatever conditions you can apply here



$product_price=$this->Model->getTableData(‘wp_postmeta’,$wc,’field_name’);


in model:
public function getTableData($tableName,$whereCondition,$tableField){
        $query = $this->db->get_where($tableName,$whereCondition);    
              $res=$query->row_array();
              return $res[$tableField];

    }


——————————————————————————————————
codeigniter search query [multiple where condition in a tiny code] *return multi row
in controller:
$wc=array(
         ‘table_field1’  =>  $where_value,
         ‘table_field2’  =>  $where_value
); //whatever conditions you can apply here



$product_price=$this->Model->getTableData(‘wp_postmeta’,$wc);


in model:
public function getTableData($tableName,$whereCondition){
        $query = $this->db->get_where($tableName,$whereCondition);        
              $res=$query->result_array();
              return $res;

    }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>