Codeigniter Datamapper 按关系排序
下午好,
我正在使用 Datamapper Overzealous Edition for Codeigniter 构建一个足球联赛网站。我的所有赛程表都存储在具有以下格式的数据库表中:
ID Competition_id Home_team_id Away_team_id Etc...
正如您所猜测的,我的比赛表具有以下格式:
ID Name
当我从数据库中获取赛程表时,我想按相关比赛名称对它们进行排序,例如,我会使用以下内容:
$fixtures = new fixtures();
$fixtures->order_by('competition/name','asc')->get();
不幸的是,order_by 函数似乎不支持这种形式的语法。有人能想出一个干净的方法来完成这个任务吗?我能想到的就是手动将每个灯具放入数组中并以这种方式排序,但这似乎有很多冗余代码!
非常感谢。
担
Good afternoon,
I am using Datamapper Overzealous Edition for Codeigniter to build a football league website. All of my fixtures are stored within a database table with the following format:
ID Competition_id Home_team_id Away_team_id Etc...
As you guessed, my competitions table has the following format:
ID Name
When I get my fixtures from the database, I would like to order them by the related competitions name so for example, I would use the following:
$fixtures = new fixtures();
$fixtures->order_by('competition/name','asc')->get();
Unfortunately, it seems that the order_by function does not support this form of syntax. Can anybody come up with a clean way to accomplish this? All I can think of is manually placing every fixture into an array and ordering that way but that would seem like alot of redundant code!
Many thanks in advance.
Dan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您必须加入表格并按所需字段进行排序。
I believe you have to join the table and sort on the field needed.