con = mysql_pconnect($db_host, $db_user, $db_pass);
if ($this->con)
{
mysql_select_db($db_name, $this->con);
}
}
function prepare($q_name, $q_text)
{
if ($this->con)
{
if ($this->debug) echo "PREPARE $q_name FROM '$q_text'
";
$res = mysql_query("PREPARE $q_name FROM '$q_text'", $this->con);
}
}
function execute($q_name, $q_x)
{
if ($this->con)
{
foreach ($q_x as $q_options)
{
$q_using = " USING ";
foreach ($q_options as $q_option)
{
$keys = array_keys($q_options, "$q_option", true);
if (!empty($keys))
{
if ($this->debug) echo "SET @$keys[0] = $q_option
";
$resource = mysql_query("SET @$keys[0] = $q_option");
$q_using = "$q_using @$keys[0],";
}
}
if (strlen($q_using) <= 7)
{
// don't pass parameters if none are supplied
$q_using = "";
}
else
{
// pass parameters but truncate the last ,
$q_using = substr($q_using, 0, strlen($q_using) - 1);
}
if ($this->debug) echo "EXECUTE $q_name $q_using
";
$res = mysql_query("EXECUTE $q_name $q_using", $this->con);
if (is_resource($res))
{
while ($row = mysql_fetch_assoc($res))
{
$results[] = $row;
}
}
}
return $results;
}
}
function unprepare($q_name)
{
if ($this->con)
{
$res = mysql_query("DEALLOCATE PREPARE $q_name", $this->con);
}
}
function errormsg()
{
return mysql_error($this->con);
}
function errorno()
{
return mysql_errno($this->con);
}
function __destruct()
{
if ($this->con)
{
mysql_close($this->con);
}
}
}
?>