Ever wonder why you got “can’t return a result set in the given context” error? Well, the doc says you need to enable CLIENT_MULTI_RESULTS using mysqli_options. I got CLIENT_MULTI_RESULTS real value via google’s codesearch. This patch below will enable stored proc call and add port support in hostname (eg: 192.168.1.51:5015).


function _connect($argHostname = NULL,
$argUsername = NULL,
$argPassword = NULL,
$argDatabasename = NULL)
{
// @ means: error surpression on
$this->_connectionID = @mysqli_init();

if (is_null($this->_connectionID))
{
// mysqli_init only fails if insufficient memory
if ($this->debug)
ADOConnection::outp("mysqli_init() failed : " . $this->ErrorMsg());
return false;
}
// Set connection options
// Not implemented now
if (function_exists('mysqli_options')) {
mysqli_options($this->_connectionID, /*CLIENT_MULTI_RESULTS*/0x20000, 1);
}
if (preg_match('/(.*)?:(\d+)/', $argHostname, $matches)) {
$argHostPort = $matches[2];
$argHostname = $matches[1];
} else
$argHostPort = NULL;

if (mysqli_real_connect($this->_connectionID,
$argHostname,
$argUsername,
$argPassword,
$argDatabasename,
$argHostPort))
{
if ($argDatabasename)
{
return $this->SelectDB($argDatabasename);
}

return true;
}
else
{
if ($this->debug)
ADOConnection::outp(”Could’t connect : ” . $this->ErrorMsg());
return false;
}
}

PS: Watch out for nasty quotes

Sphere: Related Content