[FX.php List] Date range and MySQL

Tim 'Webko' Booth tim at nicheit.com.au
Wed Jan 23 21:25:59 MST 2008


>>>
>>> In FMP, it would look like this:
>>>
>>> $findRec->AddDBParam('myDate', $startDate . '...' . $endDate);
>>>
>>> How would this translate to MySQL?
>>>
>>> Well, the actual SQL would look like:
>>> select *
>>> from table
>>> where date between [start date] and [end date]

Poking around in the FX class, the SQL stuff is handled like:

$currentQuery = "SELECT {$this->selectColumns} FROM {$this->layout} 
{$whereClause}

And by default, $whereClause is:

$whereClause = ' WHERE ' . $name . " LIKE '" . $value . "%';

We don't want that LIKe in there, so we'll specify eq, to make  
$whereClause

$whereClause = ' WHERE ' . $name . " = '" . $value . "%';


So, I'm guessing something like:

$strRange = "between ".$startDate." and ".$endDate";

findRec->AddDBParam('myDate', $strRange, 'eq');

Although that equals sign being put in there bugs me, and may cause  
problems...

Or perhaps two finds, one for gte $startDate and the other for lte  
$endDate?

Cheers

Webko


More information about the FX.php_List mailing list