I have created an import file to import my old forum from the phpbb3 system. That database is on the same server.
I created this file and saved it at /sys/CODOF/Importer/Drivers/
file named phpbb3.php:
corrected code:
<?php
namespace CODOF\Importer\Drivers;
class phpbb3 {
public $max_rows = 100;
public $post_has_topic = true;
private $db;
public function __construct($db) {
$this->db = $db;
}
public function set_prefix($prefix) {
define('DBPRE', $prefix);
}
public function get_cats() {
$qry = "SELECT b.forum_id AS cat_id, b.forum_name AS cat_name, b.forum_desc AS cat_description,
b.left_id AS cat_order, b.parent_id AS cat_pid
FROM ".DBPRE."forums AS b WHERE b.forum_type=1";
$res = $this->db->query($qry);
return $res->fetchAll();
}
public function get_topics($start) {
$qry = "SELECT t.topic_id AS topic_id, t.topic_title AS title,t.forum_id AS cat_id,t.topic_time AS topic_created,
t.topic_last_post_time AS topic_updated, t.topic_poster AS uid, t.topic_first_post_id AS post_id,
p.post_text AS message
FROM ".DBPRE."topics AS t
INNER JOIN ".DBPRE."posts AS p ON p.topic_id=t.topic_first_post_id
LIMIT $this->max_rows OFFSET $start";
$res = $this->db->query($qry);
$result = $res->fetchAll(\PDO::FETCH_ASSOC);
return $result;
}
public function get_posts($start) {
$qry = "SELECT t.forum_id AS cat_id, p.topic_id AS topic_id, p.poster_id AS uid,
p.post_id AS post_id,p.post_text AS message, p.post_time AS post_created,
p.post_time AS post_modified
FROM ".DBPRE."posts AS p
INNER JOIN ".DBPRE."topics as t ON t.topic_id=p.topic_id
LIMIT $this->max_rows OFFSET $start";
$res = $this->db->query($qry);
$result = $res->fetchAll(\PDO::FETCH_ASSOC);
return $result;
}
public function get_users($start) {
$qry = "SELECT u.user_id AS id, u.username AS username, u.username AS name, u.user_password AS pass,
u.user_email AS mail, u.user_sig AS signature, u.user_regdate AS created,
u.user_lastvisit AS last_access,
CASE WHEN u.user_rank='yes' THEN 0 ELSE 1 END AS user_status,
u.user_avatar AS avatar
FROM ".DBPRE."users AS u
LIMIT $this->max_rows OFFSET $start";
$res = $this->db->query($qry);
$result = $res->fetchAll(\PDO::FETCH_ASSOC);
return $result;
}
public function get_user_by_mail($mail) {
$qry = "SELECT user_id AS uid FROM ".DBPRE."users WHERE user_email=? ";
$obj = $this->db->prepare($qry);
$obj->execute(array($mail));
$res = $obj->fetch();
if (!empty($res)) {
return $res['uid'];
}
return false;
}
}
When I run it on my server at System/Importer I can select phpbb3. My error message is:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mydomain.phpbb3_USERS' doesn't exist' in ...
I edited all fields to correspond the fields for phpbb3 and table phpbb3_USERS does exist.
By the way, my old demo categories from the installation of Codoforum are gone now so that went well.
What am I missing here?