PHP pear数据库断开连接


php pear db disconnect

我需要手动调用disconnect()吗?

例如

    <?php
    // Create a valid DB object named $db
    // at the beginning of your program...
    require_once 'DB.php';
    $db =& DB::connect('pgsql://usr:pw@localhost/dbnam');
    if (PEAR::isError($db)) {
        die($db->getMessage());
    }
    // Proceed with a query...
    $res =& $db->query('SELECT * FROM clients');
    // Always check that result is not an error
    if (PEAR::isError($res)) {
$db->disconnect(); //??????????
        die($res->getMessage());
    }
................
working
$db->disconnect();//??????????
return $value;
    ?>

不需要断开与数据库的连接。对于长时间运行的脚本来说,使用此操作可能会有所帮助,但是一旦脚本完成,连接就会关闭。