mysql - What is wrong with this SQL for phpBB? -
updated sql: environment mysql 5.5. sql being generated through phpbb abstraction layer when see sql looks valid.
select f.*, t.*, p.*, u.*, tt.mark_time topic_mark_time, ft.mark_time forum_mark_time (phpbb_posts p cross join phpbb_users u cross join phpbb_topics t) left join phpbb_forums f on (t.forum_id = f.forum_id) left join phpbb_topics_track tt on (t.topic_id = tt.topic_id , tt.user_id = 2) left join phpbb_forums_track ft on (f.forum_id = ft.forum_id , ft.user_id = 2) p.topic_id = t.topic_id , p.poster_id = u.user_id , p.post_time > 1380495918 , p.forum_id in (7, 6, 5, 3, 4, 2, 1) , p.post_approved = 1 order t.topic_last_post_time desc, p.post_time limit 18446744073709551615
error is:
unknown column 't.topic_id' in 'on clause' [1054]
all column names exist. tables exist. aliases exist.
here's associated code:
$sql_array = array( 'select' => 'f.*, t.*, p.*, u.*, tt.mark_time topic_mark_time, ft.mark_time forum_mark_time', 'from' => array( posts_table => 'p', users_table => 'u', topics_table => 't'), 'where' => "$topics_posts_join_sql , p.poster_id = u.user_id $date_limit_sql $fetched_forums_str $new_topics_sql $remove_mine_sql $filter_foes_sql , p.post_approved = 1", 'order_by' => $order_by_sql ); $sql_array['left_join'] = array( array( 'from' => array(forums_table => 'f'), 'on' => 't.forum_id = f.forum_id' ), array( 'from' => array(topics_track_table => 'tt', forums_track_table => 'ft'), 'on' => "t.topic_id = tt.topic_id , tt.user_id = $user_id" ), array( 'from' => array(forums_track_table => 'ft'), 'on' => "f.forum_id = ft.forum_id , ft.user_id = $user_id" ) ); $sql = $db->sql_build_query('select', $sql_array);
t.topic_id = topics_track_table.topic_i
is wrong. make sure uses correct alias tt
Comments
Post a Comment