dpbsy60000 2009-05-04 20:52
浏览 24
已采纳

PEAR MDB2 executeStoredProc并返回结果集。 可能? 值得?

I've been trying to make this work for the last couple of hours. I have a simple stored proc called get_log_entries:

CREATE DEFINER=`root`@`localhost` PROCEDURE `get_log_entries`(p_min_id INT)
BEGIN
  SET p_min_id = IFNULL(p_min_id, -1);
  SELECT * FROM db_log WHERE item_id > p_min_id;
END

It's dead simple and it returns results in two columns: item_id (int) and log_description (varchar).

I am trying to execute this using MDB2 object, but so far no luck. Here's the code that is trying to do it:

$conn = MDB2::factory('mysql://myUser:myPassword@localhost/my_db');

if (PEAR::isError($conn)) {
    die ("Cannot connet to DB(10): " . $conn->getMessage());
}

// loading the Function module
$conn->loadModule('Function');

$params = array('null');

$result = $conn->executeStoredProc('get_log_entries', $params);

if (PEAR::isError($result)) {
    $msg = $result->getMessage() . "<br /><br />" . $result->getUserInfo();
    die ($msg);
}

At this point this nice error shows up with the message:

"_doQuery: [Error message: Could not execute statement] [Last executed query: CALL get_log_entries()] [Native code: 1312] [Native message: PROCEDURE wh_search.get_log_entries can't return a result set in the given context]"

Now I have a couple of questions:
1. Is it even possible to execute SPs using MDB2 and return result sets?
2. Or is it better to write a wrapper class for "native" PHP-MySQL functions myself?

Thanks!

  • 写回答

1条回答 默认 最新

  • drxzpo70788179614 2009-05-10 08:44
    关注

    Nevermind, wrapping mysqli for calling SP. Also lots of fun...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料