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...

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

报告相同问题?

悬赏问题

  • ¥20 Java-Oj-桌布的计算
  • ¥15 请问如何在openpcdet上对KITTI数据集的测试集进行结果评估?
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路