如何在 phpBB3 中重用现有的数据库连接?

发布于 2024-07-07 11:58:20 字数 153 浏览 5 评论 0原文

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

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

I am using my own db for phpbb3 forum, and I wish to insert some data from the forum into my own tables. Now, I can make my own connection and it runs my query but in trying to use the $db variable(which I think is what you're meant to use??) it gives me an error.

I would like someone to show me the bare bones which i insert my query into to be able to run it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

甜中书 2024-07-14 11:58:20

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

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

http://wiki.phpbb.com/Database_Abstraction_Layer< /a>

以下是如何执行查询的总体概述:

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);

Well.. You haven't given us very much information, but there are two things you need to do to connect and query to a database.

For phpbb, you may want to read the documentation they have presented:

http://wiki.phpbb.com/Database_Abstraction_Layer

Here is a general overview of how you'd execute a query:

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);
鱼忆七猫命九 2024-07-14 11:58:20

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

和 $resultid = mysql_query($sql,$db345);

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

I presumed that phpBB already had a connection to my database. Thus I wasnt going to use a new one? Can i make a new one and call it something else and not get an error?

And $resultid = mysql_query($sql,$db345);

Where $db345 is the name of my database connection

吹梦到西洲 2024-07-14 11:58:20
$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);
$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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文