需要调试 db_insert 但没有给出错误

发布于 2024-12-27 18:30:05 字数 329 浏览 2 评论 0原文

我在 D7 安装中有一个自定义模块。

在提交函数中,我执行以下操作:

my_custom_block_get_form_submit($form, &$form_state) {

$d = db_insert('db_launch')
->fields(array(
'uniq' => $uniq
))
->execute();

执行代码后,我在错误日志中没有收到任何错误,并且站点返回标准“此网站遇到错误”。

有谁知道我如何调试这个?我尝试了 try catch 块,但没有返回任何内容。

谢谢,

I have a custom module in a D7 installation.

In the submit function I'm doing the following:

my_custom_block_get_form_submit($form, &$form_state) {

$d = db_insert('db_launch')
->fields(array(
'uniq' => $uniq
))
->execute();

After executing the code, I get no errors in the error log, and the sites returns the standard "This website has encountered an error".

Does anyone have idea how I can debug this? I tried a try catch block but that didn't return anything.

Thanks,

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

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

发布评论

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

评论(2

月棠 2025-01-03 18:30:05

要调试此代码,您应该尝试这样做:

$query = db_insert('db_launch')
->fields(array(
'uniq' => $uniq
));

echo (string) $query ; // This will output your query that would be created with an insert.

$d = $query->execute(); // and later on you can attach the output result.

请注意,这将返回带有占位符的查询。如果您希望获取具有实际值的查询,您应该启用 devel.module ,然后:

echo dpq($query) ; // This will output your query without placeholders

To debug this code, you should try doing it this way:

$query = db_insert('db_launch')
->fields(array(
'uniq' => $uniq
));

echo (string) $query ; // This will output your query that would be created with an insert.

$d = $query->execute(); // and later on you can attach the output result.

Note that, this will return the query with placeholders. If you wish to obtain the queries with actual values, you should have devel.module enabled and then:

echo dpq($query) ; // This will output your query without placeholders
安稳善良 2025-01-03 18:30:05

要调试此代码,您应该尝试此操作。

$query = db_insert('db_launch')
 ->fields(array(
    'uniq' => $uniq
));
$res = $query->execute();
echo $res;

此代码打印 db_launch 表的自动增量 id。

To debug this code you should try this.

$query = db_insert('db_launch')
 ->fields(array(
    'uniq' => $uniq
));
$res = $query->execute();
echo $res;

This code print the auto increment id of db_launch table.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文