fixed sql error.
This commit is contained in:
parent
7d256444b3
commit
5951f34dd0
@ -431,6 +431,7 @@ function cbsonline_wpforo_topic_get_topics($args = [], &$items_count = 0, $count
|
||||
}
|
||||
}
|
||||
|
||||
$columns = ['topics', 'forumid', 'first_postid', 'userid', 'title', 'slug', 'created', 'modified', 'last_post', 'posts', 'votes', 'answers', 'views', 'meta_key', 'meta_desc', 'type', 'solved', 'closed', 'has_attach', 'private', 'status', 'name', 'email', 'prefix', 'tags'];
|
||||
$sql = 'SELECT `'.WPF()->tables->topics.'`.* FROM `'.WPF()->tables->topics.'`';
|
||||
if (!is_null($join)) {
|
||||
$sql .= $join;
|
||||
@ -442,9 +443,8 @@ function cbsonline_wpforo_topic_get_topics($args = [], &$items_count = 0, $count
|
||||
$item_count_sql = preg_replace('#SELECT.+?FROM#isu', 'SELECT count(*) FROM', $sql);
|
||||
if ($item_count_sql) {
|
||||
if (!is_null($join)) {
|
||||
$keys = ['topics', 'forumid', 'first_postid', 'userid', 'title', 'slug', 'created', 'modified', 'last_post', 'posts', 'votes', 'answers', 'views', 'meta_key', 'meta_desc', 'type', 'solved', 'closed', 'has_attach', 'private', 'status', 'name', 'email', 'prefix', 'tags'];
|
||||
foreach ($keys as $key) {
|
||||
$item_count_sql = str_replace(' `'.$key.'`', ' `'.WPF()->tables->topics.'`.`'.$key.'`', $item_count_sql);
|
||||
foreach ($columns as $column) {
|
||||
$item_count_sql = preg_replace('/([( ])`'.$column.'`/', '\1`'.WPF()->tables->topics.'`.`'.$column.'`', $item_count_sql);
|
||||
}
|
||||
}
|
||||
$items_count = WPF()->db->get_var($item_count_sql);
|
||||
@ -462,9 +462,8 @@ function cbsonline_wpforo_topic_get_topics($args = [], &$items_count = 0, $count
|
||||
}
|
||||
|
||||
if (!is_null($join)) {
|
||||
$keys = ['topics', 'forumid', 'first_postid', 'userid', 'title', 'slug', 'created', 'modified', 'last_post', 'posts', 'votes', 'answers', 'views', 'meta_key', 'meta_desc', 'type', 'solved', 'closed', 'has_attach', 'private', 'status', 'name', 'email', 'prefix', 'tags'];
|
||||
foreach ($keys as $key) {
|
||||
$sql = str_replace(' `'.$key.'`', ' `'.WPF()->tables->topics.'`.`'.$key.'`', $sql);
|
||||
foreach ($columns as $column) {
|
||||
$sql = preg_replace('/([( ])`'.$column.'`/', '\1`'.WPF()->tables->topics.'`.`'.$column.'`', $sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user