From: Derek Downey on
I'm having trouble calling stored procedures from DB_DataObject. The
issue is, it seems to be losing database information when making
multiple calls to the stored procedure (using mysqli). I want to make
sure I'm making the call properly. I realize it's suggested to use
MDB2 over DB_DO, but it's not possible in my situation to make the
switch for the time being.

Below is my example code and the error I'm getting. It makes the first
call fine, but it seems that adding more than one call increases the
chance to cause an error, but not all the time. What I mean by this
is, if i add a second call, it will fail occasionally (by hitting
refresh). If I add a third call, the second call almost always errors
out, causing any other calls to also error out. I just have no idea
why it's losing database connection.

// Example Stored Procedure: //
delimiter //
CREATE PROCEDURE testSP( IN testParam TINYINT(1) )
BEGIN
SELECT CONCAT('TEST', testParam);
END;
//

// DB_DO Class //
<?php
require_once('DB/DataObject.php');

class TestDO extends DB_DataObject {}
?>

// TEST CODE //
<?php
require_once("TestDBDO.php");

// SET PEAR CONFIG OPTIONS //
if (class_exists('PEAR')) {
$config = parse_ini_file('../data/pearConfig.ini',TRUE);
foreach($config as $class=>$values) {
$options = &PEAR::getStaticProperty($class,'options');
$options = $values;
}
}

DB_DataObject::debugLevel(5);
$obj1 = new TestDO();
$obj2 = new TestDO();
$obj3 = new TestDO();

$obj1->query("CALL TestSP(1)");
$obj2->query("CALL TestSP(2)");
$obj3->query("CALL TestSP(3)");

DB_DataObject::debugLevel(0);
?>

// DB_DO CONFIG FILE //
[DB_DataObject]
database = mysqli://hidden
debug = 0
keep_query_after_fetch = 1

[DB]
autofree = 1


// ERROR//
TestDO: ERROR: DB_Error Object
(
[error_message_prefix] =>
[mode] => 1
[level] => 1024
[code] => -14
[message] => DB Error: no database selected
[userinfo] => CALL TestSP(2) [nativecode=2013 ** Lost connection to
MySQL server during query]
[backtrace] => Array
(
[0] => Array
(
[file] => /path/to/pear/dir/DB.php
[line] => 966
[function] => PEAR_Error
[class] => PEAR_Error
[type] => ->
[args] => Array
(
[0] => DB Error: no database selected
[1] => -14
[2] => 1
[3] => 1024
[4] => CALL TestSP(2) [nativecode=2013 ** Lost connection to MySQL
server during query]
)