function loadTables() { if ($this->isExisting) { $result = $this->connection->execute("select TABLE_NAME from TABLES WHERE TABLE_TYPE='TABLE' ORDER BY TABLE_NAME"); while (is_array($row = linter_fetch_array($result))) { $this->tables[$row['TABLE_NAME']] = $row['TABLE_NAME']; } $this->connection->closeCursor($result); $this->isTablesLoaded = true; } }
function loadColumns() { $connection = $this->database->getConnection(); $result = $connection->execute(sprintf("select * from COLUMNS where TABLE_NAME='%s'", $this->name)); while (is_array($row = linter_fetch_array($result))) { $column = new lmbLinterColumnInfo($this, $row['COLUMN_NAME'], str_replace(" AUTOINC", "", $row['TYPE_NAME']), $row['COLUMN_SIZE'], $row['DECIMAL_DIGITS'], $row['NULLABLE'], null, strpos($row['TYPE_NAME'], 'AUTOINC') !== false); $name = $row['COLUMN_NAME']; $this->columns[$name] = $column; } $this->isColumnsLoaded = true; }
function at($pos) { $stmt = clone $this->stmt; if ($this->sort_params) { $stmt->addOrder($this->sort_params); } $stmt->addLimit($pos, 1); $queryId = $stmt->execute(); $arr = linter_fetch_array($queryId); if ($this->queryId > 0) { $this->connection->closeCursor($queryId); } if (is_array($arr)) { $record = new lmbLinterRecord(); $record->import($arr); return $record; } }
<?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++) {