我在 ExpressionEngine 1.6.4(非常旧的版本)中收到有关此代码的 MySQL 错误
{exp:query limit="10" paginate="bottom"
sql="SELECT 'gallery' AS `content_type`, `cat_id` AS `entry_id`, `recent_entry_date` AS `entry_date`
FROM `exp_gallery_categories`
WHERE `gallery_id` = 9 AND total_files > 0
UNION
SELECT 'video' AS `content_type`, `entry_id`, `entry_date`
FROM `exp_weblog_titles`
WHERE `weblog_id` = 6 ORDER BY `entry_date` DESC"
}
<p>{content_type} - {entry_id} - {entry_date format="%d %F %Y"}</p>
{paginate}{pagination_links}{/paginate}
{/exp:query}
MySQL 返回:
MySQL ERROR: Error Number: 1054
Description: Unknown column 'entry_date' in 'order clause'
Query: SELECT COUNT(*) AS count FROM `exp_gallery_categories` WHERE `gallery_id` = 9 AND total_files > 0 UNION SELECT COUNT(*) AS count FROM `exp_weblog_titles` WHERE `weblog_id` = 6 ORDER BY `entry_date` DESC
似乎 EE 在 MySQL 之前修改了我的查询并使其失败(在 SQL 客户端上这很顺利)。