why is PEAR::DB constantly initting connection?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



bonjour,

why does my DB object always send INIT DB to mysql server?  i am using 
PHP 5.0.5 and 
* @version    Release: 1.7.5
 * @link       http://pear.php.net/package/DB
 */


the problem caused by calls like the following -- very simple code,
really ---- may be caused by my PEAR/DB.php wrapper functions (see
below) .   evidence is my mysql query log (shown below the code, also),
please help me pinpoint the error................

    if (!$db) $db=db_connect();^M
   $this_userRS = db_query($db,$query);
    $this_user= $this_userRS->fetchRow();
    $top_bar_text =   "these are old todo list entries by "  .
$browse_user_name . " (". $this_user[0] .")";
    $max_from_db_table = $this_user[0];



i use functions like this :


function db_connect() {
    global $err,$errstring, $dsn,$mysql_host,$mysql_db,$mysql_user,
$mysql_password,$DEBUG_DICT_CONNECT,$options;
    // Retries connection to server 5 times.
    if ($DEBUG_DICT_CONNECT) echo "dsn = " . print_r($dsn) . "<br>";
    for ($i = 0; !(@$db = DB::connect($dsn,$options)) && $i < 5; $i++)
    { }
    if (DB::isError($db))
    {
        header("Location: http://"; . $_SERVER['HTTP_HOST'] .
"/index.php?cfile=err&query=" . $err . "&errstring='" . $errstring."'");
        exit;
    }
    else {
        db_query($db,"set names utf8");
         return $db;
    }
} // end db_connect

and


function db_query(&$db,$query)
{
    global $err,$errstring, $DEBUG_DICT, $tpf_admin_email;
    $result = $db->query($query);
    if (DB::isError($result))
    {
        exit;
    }
    else return $result;
}

function db_getAssoc(&$db,$query)
{
    global $err,$errstring, $DEBUG_DICT, $_SERVER, $tpf_admin_email;
    $result = $db->getAssoc($query,false,array(),
DB_FETCHMODE_ORDERED,true);
    if (DB::isError($result))
    {
        exit;
    }
    else return $result;
}


and my server query log shows up stuff like


        373 Init DB   dict_explicit
                  373 Query     select
rss_id,rss_url,rss_name,rss_cache_time,rss_listnum,rss_listtype,from_lang from rss_info where rss_user = 'curious'  and cid = '246' and from_lang='german'
                  373 Query     select cid from rss_category where
cname= 'misc' and from_lang='french'
                  373 Init DB   dict_explicit
                  373 Query     select
rss_id,rss_url,rss_name,rss_cache_time,rss_listnum,rss_listtype,from_lang from rss_info where rss_user = 'joe'  and cid = '219' and from_lang='french'
                  373 Init DB   dict_explicit
                  373 Query     select
rss_id,rss_url,rss_name,rss_cache_time,rss_listnum,rss_listtype,from_lang from rss_info where rss_user = 'curious'  and cid = '219' and from_lang='french'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux