1

我正在为 phpbb3 论坛使用我自己的数据库,我希望将论坛中的一些数据插入到我自己的表中。现在,我可以建立自己的连接并运行我的查询,但是在尝试使用 $db 变量时(我认为这是您打算使用的??)它给了我一个错误。

我希望有人向我展示我插入查询以便能够运行它的基本框架。

4

3 回答 3

1

嗯.. 您没有给我们太多信息,但是您需要做两件事来连接和查询数据库。

对于 phpbb,您可能需要阅读他们提供的文档:

http://wiki.phpbb.com/Database_Abstraction_Layer

以下是您如何执行查询的一般概述:

include($phpbb_root_path . 'includes/db/mysql.' . $phpEx);

$db = new dbal_mysql();
// we're using bertie and bertiezilla as our example user credentials. You need to fill in your own ;D
$db->sql_connect('localhost', 'bertie', 'bertiezilla', 'phpbb', '', false, false);

$sql = "INSERT INTO (rest of sql statement)";

$result = $db->sql_query($sql);
于 2008-10-06T13:59:42.343 回答
0

我假设 phpBB 已经连接到我的数据库。所以我不打算用一个新的吗?我可以制作一个新的并将其命名为其他名称而不会出错吗?

并且 $resultid = mysql_query($sql,$db345);

其中 $db345 是我的数据库连接的名称

于 2008-10-06T14:07:17.850 回答
0
$db = new dbal_mysql();
// we're using bertie and bertiezilla as our example user credentials. You need to fill in your own ;D
$db->sql_connect('localhost', 'bertie', 'bertiezilla', 'phpbb', '', false, false);

$sql = "INSERT INTO (rest of sql statement)";
$result = $db->sql_query($sql);
于 2020-08-30T02:13:23.377 回答