我試圖整合phpbb3與代碼點火器。即時通訊非常成功,但即時通訊嘗試訪問論壇數據庫,它無法正常工作。這是我目前在我的數據庫文件中所擁有的。連接到第二個數據庫CodeIgniter中不工作
/** FORUM DATABASE **/
$active_group = 'forum';
$active_record = TRUE;
$db['forum']['hostname'] = 'localhost';
$db['forum']['username'] = 'root';
$db['forum']['password'] = 'root';
$db['forum']['database'] = 'phpbb';
$db['forum']['dbdriver'] = 'mysqli';
$db['forum']['dbprefix'] = 'phpbb';
$db['forum']['pconnect'] = FALSE;
$db['forum']['db_debug'] = TRUE;
$db['forum']['cache_on'] = FALSE;
$db['forum']['cachedir'] = '';
$db['forum']['char_set'] = 'utf8';
$db['forum']['dbcollat'] = 'utf8_general_ci';
$db['forum']['swap_pre'] = '';
$db['forum']['autoinit'] = TRUE;
$db['forum']['stricton'] = TRUE;
/** CMS DATABASE **/
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'root';
$db['default']['database'] = 'cms';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = TRUE;
這裏是一個嘗試訪問數據庫的方法。它保持返回null。
public function getUserGroupMembership()
{
$forum = $this->load->database('forum',TRUE);
global $table_prefix;
$userId = $this->_user->data['user_id'];
$this->forum->select('g.group_name');
$this->forum->from($table_prefix . 'groups g');
$this->forum->from($table_prefix . 'user_group u');
$this->forum->where('u.user_id', $userId);
$this->forum->where('u.group_id', 'g.group_id', FALSE);
$query = $this->forum->get();
foreach ($query->result_array() as $group)
{
$groups[] = $group['group_name'];
}
return $groups;
}
您是否嘗試在方法的第一行用'$ this-> forum'替換'$ forum'? '$ forum'和'$ this-> forum'不是一回事。 –
如果這是這是一個答案,我將能夠給它複選標記。 –
我已經給我的答案添加了更多的肉。 :) –