Re: WHERE clause...getting closer

From: Date: Wed, 05 May 2004 00:52:47 +0000
Subject: Re: WHERE clause...getting closer
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-185384@lists.php.net to get a copy of this message
* Thus wrote msa (melissa@maddesignusa.com): > > $query_rsENews = 'SELECT * FROM NewsArchive WHERE YEAR(datePublished) = ' . > YEAR(NOW()) . ' AND MONTH(datePublished) = ' . MONTH(NOW()) . ' ORDER BY > sortBy DESC'; > > got this error: > Fatal error: Call to undefined function: year() > > any ideas, anyone? You're mixing php and mysql, you've changed from using php's date() function to mysql's functions. Not to through a whole new twist into all your problems but your query probably should be written differently: $query_rsENews = 'SELECT * FROM NewsArchive WHERE datePublished >= DATE_FORMAT(NOW(), "%Y-%m-01") ORDER BY sortBy DESC'; And add an index on the datePublished column. You'll notice a considerable speed difference. Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#185384) next »