Wednesday, March 28, 2012

Re: doubt of join in cakephp

hello,guys i got amuch perfect logic fro our cakephp buddy rodigreas..
he ask me to link from offerpromo table to offer..and use belongs to
condition and i write it like this:-
function getallhot(){
$this->belongsTo =
array('Offer'=>array('className'=>'Offer','foreignKey'=>'offer_id','counterCache'=>true));

$date=date('Y-m-d');
$dat=strtotime($date);
$end=strtotime('Offer.`end_date`');
$cond="Offer.`hot_deals`='1' AND Offer.`published`='1' AND
TO_DAYS(Offer.`end_date`)>=TO_DAYS('$date') AND
TO_DAYS(Offerpromo.`end_date`)>=TO_DAYS('$date')";

$data = $this->find('all',array('conditions'=>$cond));

/*$query="SELECT t.*,b.title FROM hly_comment AS t, hly_movies AS b
WHERE t.id=b.movie_id";
$data=mysql_query($query);*/
$this->totalRecords =count($data);

return $data;
}

now it works fine thanks:-)

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: