php - 我可以使用 PHP 获得一个带有一个 SQL 选择的单个数组吗
问题描述
我正在做一个博客网站,并希望在我的页面中显示我的所有文章。这些文章有作者和翻译(因为这是一个多语言网站)。
这是我的桌子
table : articles
rows :
- id
- release_date
- author_id
table : author
rows :
- id
- firstname
- lastname
table : translations
rows :
- id
- article_id
- translator_id
- translation_date
- language
- content
- title
我想显示所有信息,所以我想拥有这种类型的数组
articles => array(
0 => array(
id => ...
release_date => ...
author => array (
firstname => ...
lastname => ...
)
translations => array (
0 => array (
translator => array (
firstname => ...
lastname => ...
)
translation_date => ...
language => ...
content => ...
title => ...
)
1 => array(
...
)
...
)
)
1 => array(
...
)
...
)
我想要所有文章,按release_date
作者顺序排序,每种语言的最后一个翻译,对于每一个翻译,我都想要翻译
这可能在一个查询中吗?因为现在我正在做一些循环,服务器要花很多时间来回答(每篇文章用 2 种不同的语言大约需要 5 次调用,想象一下超过 100 篇文章......)
解决方案
推荐阅读
- node.js - Discord.js,战斗机器人编辑消息需要太多时间
- plotly - Javascript Plotly - 更新布局
- excel - 如何在 Excel 中创建类似于 Power BI 表可视化效果的表?
- php - 如何使用 Apache 在生产环境中打开 Laravel?
- java - 如何在 JavaFX 应用程序的后台运行 Thread?
- python - 删除列表列表中的空列表元素
- python-3.x - 在 pyspark 中查看并显示 windows.partition 函数的结果
- kdb - 如何在 kdb 中跨不同日期窗口加入
- python - 无法在 Python 3.9 上安装 PyAudio
- r - 绘图在特定点创建截止线