mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-09 21:08:53 +00:00
Fix Wrong table order in query obtaining posts if post id given. In MSSQL there is an sql error due to this bug.
git-svn-id: file:///svn/phpbb/trunk@8852 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
46b4d09e3a
commit
ca07af715f
1 changed files with 10 additions and 5 deletions
|
@ -178,12 +178,18 @@ if ($view && !$post_id)
|
||||||
$sql_array = array(
|
$sql_array = array(
|
||||||
'SELECT' => 't.*, f.*',
|
'SELECT' => 't.*, f.*',
|
||||||
|
|
||||||
'FROM' => array(
|
'FROM' => array(FORUMS_TABLE => 'f'),
|
||||||
FORUMS_TABLE => 'f',
|
|
||||||
TOPICS_TABLE => 't',
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// The FROM-Order is quite important here, else t.* columns can not be correctly bound.
|
||||||
|
if ($post_id)
|
||||||
|
{
|
||||||
|
$sql_array['FROM'][POSTS_TABLE] = 'p';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Topics table need to be the last in the chain
|
||||||
|
$sql_array['FROM'][TOPICS_TABLE] = 't';
|
||||||
|
|
||||||
if ($user->data['is_registered'])
|
if ($user->data['is_registered'])
|
||||||
{
|
{
|
||||||
$sql_array['SELECT'] .= ', tw.notify_status';
|
$sql_array['SELECT'] .= ', tw.notify_status';
|
||||||
|
@ -226,7 +232,6 @@ if (!$post_id)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id" . ((!$auth->acl_get('m_approve', $forum_id)) ? ' AND p.post_approved = 1' : '');
|
$sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id" . ((!$auth->acl_get('m_approve', $forum_id)) ? ' AND p.post_approved = 1' : '');
|
||||||
$sql_array['FROM'][POSTS_TABLE] = 'p';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id';
|
$sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id';
|
||||||
|
|
Loading…
Add table
Reference in a new issue