cakephp: find ignores DISTINCT -
cakephp: find ignores DISTINCT -
i got next cakephp find situation:
$data = $this->find('all', array( 'conditions' => array( 'roster.league_id' => $league_id, 'roster.season' => $season, ), 'fields' => array( 'distinct roster.player_id', 'roster.league_id', 'roster.fflteam_id', 'roster.season', 'roster.modified', 'fflteam.name', 'player.firstname', 'player.lastname', 'player.position' ), 'order' => array( 'roster.player_id', 'roster.modified desc'), 'contain' => array( 'fflteam', 'player' => array( 'stat' => array( 'conditions' => array( 'stat.season' => $season), 'scores'), 'teamplayer') ) ));
there more roster-records specific player_ids, thats why seek utilize distinct. need recent. thats why order results player_id , roster.modified. die distinct command gets ignored.
e.g: records:
id=1 player_id=1 modified=2012 id=2 player_id=1 modified=2013 id=3 player_id=1 modified=2014 id=4 player_id=2 modified=2014 id=5 player_id=2 modified=2013
result should be:
id=3 player_id=1 modified=2014 id=4 player_id=2 modified=2014
i don't see syntax errors. maybe there commands not possible or way of filtering wrong. great if can help me.
distinct not give 1 distinct field if there multiple fields , if have distinct title provides distinct title .
if have distinct id , title output distinct combination of rows same id , title.
this how distinct works.
try groupby check page understand utilize when http://www.mysqltutorial.org/mysql-distinct.aspx
cakephp find distinct contain
Comments
Post a Comment