added option for a table prefix when importing phpbb3

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5996 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent 1c69d9b8b6
commit 4522c13ee7

@ -906,6 +906,7 @@ content.phpbb3.dbtype = mysql
content.phpbb3.dbhost = localhost
content.phpbb3.dbport = 3306
content.phpbb3.dbname = forum
content.phpbb3.tableprefix = phpbb_
content.phpbb3.dbuser = notroot
content.phpbb3.dbpw = joshua
content.phpbb3.ppf = 1000

@ -36,6 +36,9 @@
<dt><b>Name of the database</b> on the host</dt>
<dd><input type="text" name="content.phpbb3.dbname" value="#[content.phpbb3.dbname]#" size="20" /></dd>
<dt><b>Table prefix string</b> for table names</dt>
<dd><input type="text" name="content.phpbb3.tableprefix" value="#[content.phpbb3.tableprefix]#" size="20" /></dd>
<dt><b>User</b> that can access the database</dt>
<dd><input type="text" name="content.phpbb3.dbuser" value="#[content.phpbb3.dbuser]#" size="20" /></dd>

@ -46,6 +46,7 @@ public class ContentIntegrationPHPBB3_p {
String dbhost = post.get("content.phpbb3.dbhost", "");
int dbport = post.getInt("content.phpbb3.dbport", 3306);
String dbname = post.get("content.phpbb3.dbname", "");
String prefix = post.get("content.phpbb3.tableprefix", "");
String dbuser = post.get("content.phpbb3.dbuser", "");
String dbpw = post.get("content.phpbb3.dbpw", "");
int ppf = post.getInt("content.phpbb3.ppf", 1000);
@ -56,6 +57,7 @@ public class ContentIntegrationPHPBB3_p {
sb.setConfig("content.phpbb3.dbhost", dbhost);
sb.setConfig("content.phpbb3.dbport", dbport);
sb.setConfig("content.phpbb3.dbname", dbname);
sb.setConfig("content.phpbb3.tableprefix", prefix);
sb.setConfig("content.phpbb3.dbuser", dbuser);
sb.setConfig("content.phpbb3.dbpw", dbpw);
sb.setConfig("content.phpbb3.ppf", ppf);
@ -68,6 +70,7 @@ public class ContentIntegrationPHPBB3_p {
dbhost,
dbport,
dbname,
prefix,
dbuser,
dbpw
);
@ -92,6 +95,7 @@ public class ContentIntegrationPHPBB3_p {
dbhost,
dbport,
dbname,
prefix,
dbuser,
dbpw
);
@ -114,6 +118,7 @@ public class ContentIntegrationPHPBB3_p {
prop.putHTML("content.phpbb3.dbhost", sb.getConfig("content.phpbb3.dbhost", ""));
prop.putHTML("content.phpbb3.dbport", sb.getConfig("content.phpbb3.dbport", ""));
prop.putHTML("content.phpbb3.dbname", sb.getConfig("content.phpbb3.dbname", ""));
prop.putHTML("content.phpbb3.tableprefix", sb.getConfig("content.phpbb3.tableprefix", ""));
prop.putHTML("content.phpbb3.dbuser", sb.getConfig("content.phpbb3.dbuser", ""));
prop.putHTML("content.phpbb3.dbpw", sb.getConfig("content.phpbb3.dbpw", ""));
prop.putHTML("content.phpbb3.ppf", sb.getConfig("content.phpbb3.ppf", ""));

@ -47,7 +47,7 @@ import de.anomic.yacy.yacyURL;
public class PhpBB3Dao implements Dao {
private Connection conn = null;
private String urlstub;
private String urlstub, prefix;
private HashMap<Integer, String> users;
public PhpBB3Dao(
@ -56,10 +56,12 @@ public class PhpBB3Dao implements Dao {
String host,
int port,
String dbname,
String prefix,
String user,
String pw) throws Exception {
this.conn = getConnection(dbType, host, port, dbname, user, pw);
this.urlstub = urlstub;
this.prefix = prefix;
this.users = new HashMap<Integer, String>();
}
@ -103,7 +105,7 @@ public class PhpBB3Dao implements Dao {
public Date first() {
StringBuilder sql = new StringBuilder(256);
sql.append("select min(post_time) from phpbb_posts");
sql.append("select min(post_time) from " + prefix + "posts");
Statement stmt = null;
ResultSet rs = null;
try {
@ -124,7 +126,7 @@ public class PhpBB3Dao implements Dao {
public Date latest() {
StringBuilder sql = new StringBuilder(256);
sql.append("select max(post_time) from phpbb_posts");
sql.append("select max(post_time) from " + prefix + "posts");
Statement stmt = null;
ResultSet rs = null;
try {
@ -148,7 +150,7 @@ public class PhpBB3Dao implements Dao {
ResultSet rs = null;
try {
stmt = conn.createStatement();
rs = stmt.executeQuery("select count(*) from phpbb_posts");
rs = stmt.executeQuery("select count(*) from " + prefix + "posts");
if (rs.next()) {
return rs.getInt(1);
}
@ -164,7 +166,7 @@ public class PhpBB3Dao implements Dao {
public DCEntry get(int item) {
StringBuilder sql = new StringBuilder(256);
sql.append("select * from phpbb_posts where post_id = ");
sql.append("select * from " + prefix + "posts where post_id = ");
sql.append(item);
return getOne(sql);
}
@ -172,7 +174,7 @@ public class PhpBB3Dao implements Dao {
public BlockingQueue<DCEntry> query(int from, int until, int queueSize) {
// define the sql query
final StringBuilder sql = new StringBuilder(256);
sql.append("select * from phpbb_posts where post_id >= ");
sql.append("select * from " + prefix + "posts where post_id >= ");
sql.append(from);
if (until > from) {
sql.append(" and post_id < ");
@ -187,7 +189,7 @@ public class PhpBB3Dao implements Dao {
public BlockingQueue<DCEntry> query(Date from, int queueSize) {
// define the sql query
final StringBuilder sql = new StringBuilder(256);
sql.append("select * from phpbb_posts where post_time >= ");
sql.append("select * from " + prefix + "posts where post_time >= ");
sql.append(from.getTime() / 1000);
sql.append(" order by post_id");
@ -286,7 +288,7 @@ public class PhpBB3Dao implements Dao {
if (nick != null) return nick;
StringBuilder sql = new StringBuilder(256);
sql.append("select * from phpbb_users where user_id = ");
sql.append("select * from " + prefix + "users where user_id = ");
sql.append(poster_id);
Statement stmt = null;
ResultSet rs = null;
@ -375,6 +377,7 @@ public class PhpBB3Dao implements Dao {
"localhost",
3306,
"forum",
"forum_",
"root",
""
);

Loading…
Cancel
Save