脚本宝典收集整理的这篇文章主要介绍了Cakephp分页与连接表字段排序不工作,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
看下面的示例代码..我有Artist.name连接表字段顺序.
$this->paginate = array( 'fields' => array( 'id','Song.tITle','Song.date','Artist.id AS artist_id','Artist.name AS artist_name','COUNT(SongViews.id) AS views' ),'group' => array('ArtistsSong.song_id'),'recursive' => 0,'limit' => 20,'joins' => array( array( 'table' => 'tbl_artists_songs','alias' => 'ArtistsSong','conditions'=> array('Song.id = ArtistsSong.song_id') ),array( 'table' => 'tbl_artists','alias' => 'Artist','conditions'=> array('Artist.id = ArtistsSong.artist_id') ),array( 'table' => 'tbl_song_views','alias' => 'SongViews','tyPE' => 'left','conditions'=> array('SongViews.song_id = ArtistsSong.song_id') ),),'order' => array('Artist.name'=>'asc') );
$this->Song->virtualFields = array( 'artist_name' => 'Artist.name' );
现在,您可以按artist_name排序.
以上是脚本宝典为你收集整理的Cakephp分页与连接表字段排序不工作全部内容,希望文章能够帮你解决Cakephp分页与连接表字段排序不工作所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。