Welcome Guest, Not a member yet? Register   Sign In
Transform query ( of query builder in query model
#2

Solved in this way :

PHP Code:
if(!empty($post['data_da'])){

                $data_da date_local_format_to_iso($post['data_da']);
            
            
}else{

                $data_da ='2000/01/01';
            }

            if(!empty($post['data_a'])){

                $data_a date_local_format_to_iso($post['data_a']);
            
            
}else{

                $data_a ='2100/01/01';
            }

            $array_query=[];

            if(!empty($post['id_tipo_spesa'])){

                $id_tipo_spesa $post['id_tipo_spesa'];
                
                $array_query 
['id_tipo_spesa']    $id_tipo_spesa;
            }
                
            
if(!empty($post['id_tipo_pagamento'])){

                $id_tipo_pagamento $post['id_tipo_pagamento'];
                
                $array_query 
["id_tipo_pagamento"]  =  $id_tipo_pagamento;
            }
                

                
            
if(!empty($post['id_autisti_interni'])){

                $id_autisti_interni $post['id_autisti_interni'];
                
                $array_query 
["id_autisti_interni"] =  $id_autisti_interni;
            }
                                
            
if(!empty($post['id_mezzi'])){

                $id_mezzi $post['id_mezzi'];
                
                $array_query 
["id_mezzi"] =  $id_mezzi;
            }
                

            
if(!count($array_query)){
                $array_query="id!=0";
            }
                


            $spese 
$spese_model->where('data>=',$data_da)
                                ->where('data<=',$data_a)
                                ->where($array_query)
                                ->findAll();


            
            
//log_message('debug',$spese_model->getLastQuery());
            $record_totali =$spese_model->countAllResults(); 
Reply


Messages In This Thread
RE: Transform query ( of query builder in query model - by pippuccio76 - 10-24-2021, 10:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB