question regarding 'where' clause

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

By kovali - February 7, 2011

Hi,

I am using this where clause: 'where' => 'year=2011',
This shows me all the records for the year 2011

Question: Is it possible to use some php code (instead of the fixed value 2011) that will automatically fill in the current year ? So next year I don't have to change it manually to 2012... and so on for every next year ??

Thanks for your help,
Koen

Re: [kovali] question regarding 'where' clause

By Jason - February 8, 2011

Hi Koen,

You can use the php date() function to get the current year from the server like this:

$currentYear = date("Y");

You can then use it in your where clause like this:

'where' => "year = '$currentYear'",

In this example, it's important to use the double quotes (").

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/