current year in where clause

2 posts by 1 authors in: Forums > CMS Builder
Last Post: February 8, 2011   (RSS)

By kovali - February 8, 2011

Hi,

I would like to show only the results of the current year in the list page, my code:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
// load viewer library
$libraryPath = 'beheer/lib/viewer_functions.php';
$dirsToCheck = array('/home/yannicke/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

$var = date("Y", time());

// load records
list($resultatenRecords, $resultatenMetaData) = getRecords(array(
'tableName' => 'resultaten',
'where' => 'year=$var',
'perPage' => '10',
'orderBy' => 'datum DESC, title',
'loadUploads' => '0',
'allowSearch' => '0',
));

?>

I am new to php so forgive me my asking, but:

'where' => 'year=$var',
doesn't work...

When I change $var with a fixed value like 2011, I get all the records for this year though... how can this be done please ?

Thx,
Koen