protected function handle_cursor_pool() { if (!$this->useConnection) { if (count($this->cursorPool) > self::CURSOR_POOL_LIMIT) { $cursors = array_keys($this->cursorPool); $this->closeCursor($cursors[0]); } $result = linter_open_cursor($this->getConnectionId()); if ($result < 0) { $this->_raiseError($result); } $this->cursorPool[$result] = "opened"; $this->log("Cursor opened. Connection: " . $this->connectionId . "; cursor: " . $result . "; pool size: " . count($this->cursorPool)); } else { $result = true; } return $result; }
<?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++) {