What is wrong with this condition?
i getting errors if one of my conditions is:
$conditions[] = array("PublicationNumeration.publication_numerations_published_date" => '2006-01-01' );
what is wrong with this condition?
but everything works ok with
$conditions[] = array("PublicationNumeration.publication_numerations_published_date" => '2006' );
... but that's not all i want/need.
what i'm doing wrong?
UPDATED:
next one works ok:
$mydate = '2007/01/01';
$conditions[] = array("PublicationNumeration.publication_numerations_published_dat开发者_如何学JAVAe LIKE " => date('Y-m-d' , strtotime( $mydate ) ) );
// create sql `PublicationNumeration`.`publication_numerations_published_date` LIKE '2007-01-01'
but next one creates an error:
$mydate = $this->params['named']['searchPublishedSince'].'/01/01'; // searchPublishedSince is defined in url
$conditions[] = array("PublicationNumeration.publication_numerations_published_date LIKE " => date('Y-m-d' , strtotime( $mydate ) ) );
please, what i'm doing wrong?!
Make sure you follow the scheme:
$conditions = array("Post.title" => "This is a post");
//Example usage with a model:
$this->Post->find('first', array('conditions' => $conditions));
See that it is an array in an array.
Kind regards.
Edit1: BTW you can have a look into the "automagic" of cake e.g. the columns in a database named created
or modified
get autoupdated.
Edit2: maybe a debug($this->params['named']['searchPublishedSince'])
reveals something.
I've never used CakePHP before, but what I gather from the documentation is that those date strings should probably be actual dates. What is the condition you actually want? Do you want a filter that returns publications on Jan 01, 2006, or all greater than Jan 01, 2006?
For publications ON Jan 01, 2006, perhaps try:
$conditions[] = array("PublicationNumeration.publication_numerations_published_date" => date('Y-m-d', strtotime('2006-01-01')));
For all publications >= to Jan 01, 2006, try:
$conditions[] = array("PublicationNumeration.publication_numerations_published_date >=" => date('Y-m-d', strtotime('2006-01-01')));
精彩评论