PHP Classes

Feature Request

Recommend this page to a friend!

      Ultimate MySQL  >  All threads  >  Feature Request  >  (Un) Subscribe thread alerts  
Subject:Feature Request
Summary:WHERE clause to incorporate ranges (ie: date ranges)
Messages:3
Author:Jason Williams
Date:2008-04-15 01:23:26
Update:2008-04-15 01:55:15
 

  1. Feature Request   Reply   Report abuse  
Picture of Jason Williams Jason Williams - 2008-04-15 01:23:26
Firstly, great work.

A useful addition to this class would be the ability to incorporate ranges into the BuildSQLWhereClause...

From what I can see, the current build where clause will only work with exact matches
(WHERE 'queryDate' = 2008-04-15)
and not ranges
(WHERE 'queryDate' BETWEEN $startDate AND $endDate)
or
(WHERE 'queryDate' >= $startDate)
or
(WHERE 'queryDate' <= $endDate)

  2. Re: Feature Request   Reply   Report abuse  
Picture of Jason Williams Jason Williams - 2008-04-15 01:42:45 - In reply to message 1 from Jason Williams
as an interim, the below code will allow for the same result to be achieved...
(for those wondering how to get around it)

if(($startDate != NULL)&&($endDate != NULL)) {
$where[] = "'queryDate' >= $startDate AND 'queryDate' <= $endDate";
} elseif (($startDate != NULL)&&($endDate == NULL)) {
$where[] = "'queryDate' >= $startDate";
} elseif (($startDate == NULL)&&($endDate != NULL)) {
$where[] = "'queryDate' <= $endDate";
} else {
$where[] = NULL;
};

  3. Re: Feature Request   Reply   Report abuse  
Picture of Jason Williams Jason Williams - 2008-04-15 01:55:15 - In reply to message 2 from Jason Williams
if(($startDate != NULL)&&($endDate != NULL)) {
$where[] = "'queryDate' BETWEEN $startDate AND $endDate";
} elseif (($startDate != NULL)&&($endDate == NULL)) {
$where[] = "'queryDate' >= $startDate";
} elseif (($startDate == NULL)&&($endDate != NULL)) {
$where[] = "'queryDate' <= $endDate";
} else {
$where[] = NULL;
};