Welcome Guest, Not a member yet? Register   Sign In
Gets too much data
#1

(This post was last modified: 04-24-2015, 01:05 PM by Toddles.)

Hello all I have this database query but I get all dates back to 2010 and not in the range selected..

SELECT* FROM ( `morning_qa` )
WHERE`qa_date`>='2014-04-24'
AND`qa_date`<='2015-04-24'
AND`qa_type`='iris'
OR`qa_type`='cones'
ORDERBY`qa_date`;

PHP Code:
function morningQA_getall($range_type$range_num$qa_year$qa_type){
        
$date_last date("Y-m-d");

        if (
$range_type == "year"){
            
$num "-".$range_num." year";
            
$date_start date("Y-m-d"strtotime($num));
        }

        if (
$range_type == "month"){
            
$num "-".$range_num." month";
            
$date_start date("Y-m-d"strtotime($num));
        }

        if (
$qa_year != NULL){
            
$date_start date($qa_year."-01-01");
            
$date_last date($qa_year."-12-31");
        }
        
$this->db->where('qa_date >='$date_start);
        
$this->db->where('qa_date <='$date_last);
        if (
$qa_type == "iris"){
            
$this->db->where('qa_type'$qa_type);
        }
        if (
$qa_type == "cones"){
            
$this->db->where('qa_type'$qa_type);
        }
        if (
$qa_type == "both"){
            
$this->db->where('qa_type'"iris");
            
$this->db->or_where('qa_type'"cones");
        }
        

        
$this->db->order_by("qa_date");
        
$query=$this->db->get('morning_qa');

        return 
$query->result_array();
    } 


Not sure why. It doesn't like the both clause. Works fine for either cones or iris on their own.
Reply


Messages In This Thread
Gets too much data - by Toddles - 04-24-2015, 01:03 PM
RE: Gets too much data - by CroNiX - 04-24-2015, 01:13 PM
RE: Gets too much data - by Toddles - 04-24-2015, 01:18 PM
RE: Gets too much data - by CroNiX - 04-24-2015, 01:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB