mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Use a left join for the topics table on search to avoid trouble with FROM syntax on some databases (Bug #37005)
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9172 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -455,6 +455,7 @@ class fulltext_native extends search_backend
|
||||
);
|
||||
|
||||
$title_match = '';
|
||||
$left_join_topics = false;
|
||||
$group_by = true;
|
||||
// Build some display specific sql strings
|
||||
switch ($fields)
|
||||
@@ -464,7 +465,7 @@ class fulltext_native extends search_backend
|
||||
$group_by = false;
|
||||
// no break
|
||||
case 'firstpost':
|
||||
$sql_array['FROM'][TOPICS_TABLE] = 't';
|
||||
$left_join_topics = true;
|
||||
$sql_where[] = 'p.post_id = t.topic_first_post_id';
|
||||
break;
|
||||
|
||||
@@ -476,11 +477,7 @@ class fulltext_native extends search_backend
|
||||
|
||||
if ($type == 'topics')
|
||||
{
|
||||
if (!isset($sql_array['FROM'][TOPICS_TABLE]))
|
||||
{
|
||||
$sql_array['FROM'][TOPICS_TABLE] = 't';
|
||||
$sql_where[] = 'p.topic_id = t.topic_id';
|
||||
}
|
||||
$left_join_topics = true;
|
||||
$group_by = true;
|
||||
}
|
||||
|
||||
@@ -688,11 +685,7 @@ class fulltext_native extends search_backend
|
||||
break;
|
||||
|
||||
case 't':
|
||||
if (!isset($sql_array['FROM'][TOPICS_TABLE]))
|
||||
{
|
||||
$sql_array['FROM'][TOPICS_TABLE] = 't';
|
||||
$sql_where[] = 'p.topic_id = t.topic_id';
|
||||
}
|
||||
$left_join_topics = true;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
@@ -700,6 +693,14 @@ class fulltext_native extends search_backend
|
||||
$sql_where[] = 'f.forum_id = p.forum_id';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($left_join_topics)
|
||||
{
|
||||
$sql_array['LEFT_JOIN'][$left_join_topics] = array(
|
||||
'FROM' => TOPICS_TABLE => 't',
|
||||
'ON' => 'p.topic_id = t.topic_id'
|
||||
);
|
||||
}
|
||||
|
||||
$sql_array['WHERE'] = implode(' AND ', $sql_where);
|
||||
$sql_array['GROUP_BY'] = ($group_by) ? (($type == 'posts') ? 'p.post_id' : 'p.topic_id') . ', ' . $sort_by_sql[$sort_key] : '';
|
||||
|
Reference in New Issue
Block a user