【问题标题】:how to debug the cause of problem using pear mdb2如何使用 pear mdb2 调试问题原因
【发布时间】:2011-06-04 07:10:02
【问题描述】:
<?php

 include("PEAR/MDB2.php");
      $dsn = 'mysqli://root@localhost/heart_hugger';
$options = array(
    'debug' => 2,
    'result_buffering' => false,
);

$mdb2 =& MDB2::singleton($dsn, $options);
if (PEAR::isError($mdb2)) {
    die($mdb2->getMessage());
}


$table_name = 'cms';

// if left as a non array all fields of the table will be fetched using '*'
// in that case this variable can be set to true, to autodiscover the types
$result_types = "";

$mdb2->loadModule('Extended');
$res = $mdb2->extended->autoExecute($table_name, null,
                        MDB2_AUTOQUERY_SELECT, 'cmsId = '.$mdb2->quote(1, 'integer'),
                        null, true, $table_name);

if (PEAR::isError($res)) {
    die($res->getMessage());
}

$row = $res->fetchRow();
echo "value from fetchrow = ".$row[2];


$mdb2->disconnect();
?>

我收到以下错误

MDB2 错误:不支持

我不知道到底什么是不支持的。上面的代码是pear在MDB2手册中给出的一个例子。有人可以建议我缺少什么吗?谢谢

【问题讨论】:

  • die() 调用中的哪一个给您不支持的错误?另外,$res-&gt;getUserInfo() 告诉你什么?
  • 感谢您的回复,我在本地主机上运行它,只有 root 用户
  • 你能告诉我如何检查 die() 调用中的哪一个吗?
  • MDB2 错误:不支持 checkResultTypes:[错误消息:0 的 cms 不是受支持的列类型] [上次执行的查询:SELECT * FROM cms WHERE cmsId = 1] [本机代码:0]

标签: php pear mdb2


【解决方案1】:

首先,调试哪些 die 调用正在回显消息:

die('first: ' . $res->getMessage());

之后,查看扩展用户信息:

die($res->getMessage() . "\n" . $res->getUserInfo());

这应该会给你一个关于真正问题的提示。

【讨论】:

  • 这就是我得到的 MDB2 错误:不支持 checkResultTypes:[错误消息:0 的 cms 不是受支持的列类型] [上次执行的查询:SELECT * FROM cms WHERE cmsId = 1] [本机代码:0]
  • 似乎“autoExecute”参数与 API 所说的不匹配。用pear.php.net/package/MDB2/docs/2.4.1/MDB2/…检查它
  • 感谢我已修复它,文档是抽象的,有些人需要继承它们并提供更多详细信息...谢谢@cweiske。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-11-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多