function connect()
 {
     $persistent = null;
     if (isset($this->config['charset']) && ($charset = $this->config['charset'])) {
         $r = linter_set_codepage($this->map_charset($this->config['charset']));
     }
     $port = $this->config['port'];
     $database = addslashes($this->config['database']);
     $user = addslashes($this->config['user']);
     $password = addslashes($this->config['password']);
     if (is_null($this->mode)) {
         $this->mode = isset($this->config['extra']['mode']) ? $this->config['extra']['mode'] : TM_AUTOCOMMIT;
     }
     $conn = @linter_open_connect($user, $password, $database, $this->mode);
     $this->connectionId = $conn;
     if ($conn < 0) {
         $this->_raiseError($conn);
         $this->connectionId = null;
         $this->log("Connection failed");
     } else {
         $this->log("Connected in mode " . $this->mode . ". Connection #" . $this->connectionId);
         linter_set_cursor_opt($this->connectionId, CO_NULL_AS_NULL_OBJECT, 1);
         linter_set_cursor_opt($this->connectionId, CO_FETCH_BLOBS_AS_USUAL_DATA, 1);
         linter_set_cursor_opt($this->connectionId, CO_DT_FORMAT, "YYYY-MM-DD HH:MI:SS");
         //linter_set_cursor_opt($this->connectionId, CO_DECIMAL_AS_DOUBLE, 1);
     }
 }
Example #2
0
<?php

set_include_path(dirname(__FILE__) . '/../../../../');
$mark = microtime(true);
require_once 'limb/core/common.inc.php';
require_once 'limb/dbal/common.inc.php';
echo "dbal common includes: " . (microtime(true) - $mark) . "\n";
$linter_db = linter_open_connect('SYSTEM', 'MANAGER', 'Demo', TM_AUTOCOMMIT);
$cur = linter_open_cursor($linter_db);
linter_exec_direct($cur, 'CREATE OR REPLACE TABLE "foo" ("bar" varchar(10));');
linter_exec_direct($cur, 'INSERT INTO "foo" VALUES (\'some value\');');
$mark = microtime(true);
for ($i = 0; $i < 1000; $i++) {
    linter_exec_direct($cur, 'SELECT "bar" FROM "foo";');
    while (is_array($entry = linter_fetch_array($cur))) {
        $bar = $entry['bar'];
    }
}
echo "native linter fetching: " . (microtime(true) - $mark) . "\n";
$conn = lmbDBAL::newConnection('linter://*****:*****@localhost/Demo');
$mark = microtime(true);
for ($i = 0; $i < 1000; $i++) {
    $rs = lmbDBAL::fetch('SELECT "bar" FROM "foo";', $conn);
    foreach ($rs as $record) {
        $bar = $record['bar'];
    }
    $rs->freeQuery();
}
echo "lmbDBAL :: fetch(), array access: " . (microtime(true) - $mark) . "\n";
$mark = microtime(true);
for ($i = 0; $i < 1000; $i++) {