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

(This post was last modified: 10-24-2021, 06:50 AM by pippuccio76.)

, sorry for english , i have this query :

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';
            }


            $query_creata "SELECT * from spese WHERE data>='$data_da' and data<='$data_a' ";


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

                $id_tipo_spesa $post['id_tipo_spesa'];
                
                $query_creata 
.= " AND id_tipo_spesa= $id_tipo_spesa";
            }
                
            
if(!empty($post['id_tipo_pagamento'])){

                $id_tipo_pagamento $post['id_tipo_pagamento'];
                
                $query_creata 
.= " AND id_tipo_pagamento= $id_tipo_pagamento";
                           

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

                $id_tipo_pagamento $post['id_tipo_pagamento'];
                
                $query_creata 
.= " AND id_tipo_pagamento= $id_tipo_pagamento";
            }
                





            $query 
$db->query($query_creata);
            $spese $query->getResult(); 


this is a little part
PHP Code:
$spese $spese_model->where('data_da>=',$data_da)
                                ->where('data_a<=',$data_a)
                                ->findAll(); 


how can i insert conditional ?
Reply


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



Theme © iAndrew 2016 - Forum software by © MyBB