示例#1
0
        $dbType = CL_DB_MYSQL;
        break;
    case "pgsql":
        $dbType = CL_DB_PGSQL;
        break;
    default:
        $dbType = CL_DB_NONE;
}
// Establish the database connection.
// Later AJAX code will look at $dbConn->connect_errno and retun a small XML
// file in the failed case.
try {
    // TODO: Try persistent connections.
    $dbConn = new PDO($pdo_dsn, $dbuser, $dbpass, array(PDO::ATTR_PERSISTENT => true));
    if (strlen($dbschema) && $dbType == CL_DB_PGSQL) {
        $dbschemaQ = quoteMySQLStyle($dbschema);
        $dbConn->query("SET search_path = '{$dbschemaQ}'");
    }
    unset($dbConnError);
} catch (PDOException $e) {
    $dbConnError = $e;
}
// Some timezone must be set for the date() function.  Hopefully the correct
// TZ is set via date.timezone in php*.ini.
error_reporting(E_ALL ^ (E_WARNING | E_NOTICE));
date_default_timezone_set(date_default_timezone_get());
error_reporting(E_ALL ^ E_NOTICE);
// Common functions.
function getMsec()
{
    list($usec, $sec) = explode(" ", microtime());
示例#2
0
         $dbResult = $dbConn->query($sql);
         $dbChanged = true;
     }
 }
 // Here something like XPath or retrieving "caller" directly might be more
 // succinct.  But always traversing from the trunk is straightforward.
 $callersEls = $updateXML->getElementsByTagName("callers");
 foreach ($callersEls as $callersEl) {
     foreach ($callersEl->childNodes as $callerEl) {
         $itemA = array();
         if (!$callerEl->childNodes) {
             continue;
             // Ignore whitespace.
         }
         foreach ($callerEl->childNodes as $itemEl) {
             $itemA[$itemEl->nodeName] = quoteMySQLStyle($itemEl->nodeValue);
         }
         // Note that the time is not sent.  The current time is used for
         // inserts.
         $id = $itemA["id"];
         $line = $itemA["line"];
         $priority = $itemA["priority"];
         $online = $itemA["online"];
         $name = $itemA["name"];
         $topic = $itemA["topic"];
         // Determine if the line specified is currently online
         $sql = "SELECT count(*) " . "FROM   cl_callers " . "WHERE  id     = '{$id}' " . "AND    online = '1'";
         clLog($sql);
         $dbResult = $dbConn->query($sql);
         if ($dbResult) {
             $count = $dbResult->fetchColumn();