[limb-svn] r6911 - in 3.x/trunk/limb/dbal: src/drivers src/drivers/mysqli src/dump tests/cases/driver tests/cases/driver/mysqli tests/cases/non-driver/.fixture
svn at limb-project.com
svn at limb-project.com
Thu Apr 10 16:57:30 MSD 2008
Author: korchasa
Date: 2008-04-10 16:57:30 +0400 (Thu, 10 Apr 2008)
New Revision: 6911
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6911
Added:
3.x/trunk/limb/dbal/src/drivers/mysqli/
3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliColumnInfo.class.php
3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliConnection.class.php
3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliDbInfo.class.php
3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliInsertStatement.class.php
3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliManipulationStatement.class.php
3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliQueryStatement.class.php
3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliRecord.class.php
3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliRecordSet.class.php
3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliStatement.class.php
3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliTableInfo.class.php
3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliTypeInfo.class.php
3.x/trunk/limb/dbal/src/dump/lmbMysqliDumpLoader.class.php
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/.skipif.php
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/fixture.inc.php
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliColumnInfoTest.class.php
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliConnectionTest.class.php
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliDbInfoTest.class.php
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliDeleteTest.class.php
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliDriverTransactionTest.class.php
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliInsertTest.class.php
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliQueryTest.class.php
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliRecordSetTest.class.php
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliRecordTest.class.php
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliStatementTest.class.php
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliTableInfoTest.class.php
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliTypeInfoTest.class.php
3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliUpdateTest.class.php
3.x/trunk/limb/dbal/tests/cases/non-driver/.fixture/init_tests.mysqli
Log:
-- initial realization mysqli driver
Added: 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliColumnInfo.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliColumnInfo.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliColumnInfo.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,70 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+lmb_require('limb/dbal/src/drivers/lmbDbColumnInfo.class.php');
+lmb_require(dirname(__FILE__) . '/lmbMysqliTypeInfo.class.php');
+
+/**
+ * class lmbMysqliColumnInfo.
+ *
+ * @package dbal
+ * @version $Id: lmbMysqliColumnInfo.class.php 6243 2007-08-29 11:53:10Z pachanga $
+ */
+class lmbMysqliColumnInfo extends lmbDbColumnInfo
+{
+ protected $nativeType;
+ protected $isAutoIncrement;
+ protected $isExisting = false;
+
+ function __construct(
+ $table,
+ $name,
+ $nativeType = null,
+ $size = null,
+ $scale = null,
+ $isNullable = null,
+ $default = null,
+ $isAutoIncrement = null,
+ $isExisting = false)
+ {
+
+ $this->nativeType = $this->canonicalizeNativeType($nativeType);
+ $this->isAutoIncrement = $this->canonicalizeIsAutoincrement($isAutoIncrement);
+
+ $typeinfo = new lmbMysqliTypeInfo();
+ $typemap = $typeinfo->getNativeToColumnTypeMapping();
+ $type = $typemap[$nativeType];
+
+ $this->isExisting = $isExisting;
+
+ parent::__construct($table, $name, $type, $size, $scale, $isNullable, $default);
+ }
+
+ function getNativeType()
+ {
+ return $this->nativeType;
+ }
+
+ function canonicalizeNativeType($nativeType)
+ {
+ return $nativeType;
+ }
+
+ function isAutoIncrement()
+ {
+ return $this->isAutoIncrement === true;
+ }
+
+
+ function canonicalizeIsAutoIncrement($isAutoIncrement)
+ {
+ return is_null($isAutoIncrement) ? null : (bool) $isAutoIncrement;
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliConnection.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliConnection.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliConnection.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,205 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/dbal/src/drivers/lmbDbConnection.interface.php');
+lmb_require(dirname(__FILE__) . '/lmbMysqliDbInfo.class.php');
+lmb_require(dirname(__FILE__) . '/lmbMysqliQueryStatement.class.php');
+lmb_require(dirname(__FILE__) . '/lmbMysqliInsertStatement.class.php');
+lmb_require(dirname(__FILE__) . '/lmbMysqliManipulationStatement.class.php');
+lmb_require(dirname(__FILE__) . '/lmbMysqliStatement.class.php');
+lmb_require(dirname(__FILE__) . '/lmbMysqliTypeInfo.class.php');
+
+/**
+ * class lmbMysqlConnection.
+ *
+ * @package dbal
+ * @version $Id: lmbMysqlConnection.class.php 6848 2008-03-21 13:44:08Z svk $
+ */
+class lmbMysqliConnection implements lmbDbConnection
+{
+
+ protected $connectionId;
+ protected $config;
+
+ function __construct($config)
+ {
+ $this->config = $config;
+ }
+
+ function getType()
+ {
+ return 'mysql';
+ }
+
+ function getConnectionId()
+ {
+ if(!isset($this->connectionId))
+ {
+ $this->connect();
+ }
+ return $this->connectionId;
+ }
+
+ function getHash()
+ {
+ return crc32(serialize($this->config));
+ }
+
+ function connect()
+ {
+ $this->connectionId = mysqli_connect($this->config['host'],
+ $this->config['user'],
+ $this->config['password']);
+
+ if($this->connectionId === false)
+ {
+ $this->_raiseError();
+ }
+
+ if(mysqli_select_db( $this->connectionId, $this->config['database']) === false)
+ {
+ $this->_raiseError();
+ }
+
+ if(isset($this->config['charset']) && $charset = $this->config['charset'])
+ {
+ mysqli_query($this->connectionId, "SET NAMES '$charset'");
+ }
+
+ }
+
+ function __wakeup()
+ {
+ $this->connectionId = null;
+ }
+
+ function disconnect()
+ {
+ if($this->connectionId)
+ {
+ mysqli_close($this->connectionId);
+ $this->connectionId = null;
+ }
+ }
+
+ function _raiseError($sql = null)
+ {
+ if(!$this->getConnectionId())
+ throw new lmbDbException('Could not connect to host "' . $this->config['host'] . '" and database "' . $this->config['database'] . '"');
+
+ $errno = mysqli_errno($this->getConnectionId());
+ $id = 'DB_ERROR';
+ $info = array('driver' => 'lmbMysql');
+ if($errno != 0)
+ {
+ $info['errorno'] = $errno;
+ $info['error'] = mysqli_error($this->getConnectionId());
+ $id .= '_MESSAGE';
+ }
+ if(!is_null($sql))
+ {
+ $info['sql'] = $sql;
+ $id .= '_SQL';
+ }
+ throw new lmbDbException(mysqli_error($this->getConnectionId()) . ' SQL: '. $sql, $info);
+ }
+
+ function execute($sql)
+ {
+ $result = mysqli_query($this->getConnectionId(), $sql);
+ if($result === false)
+ {
+ $this->_raiseError($sql);
+ }
+ return $result;
+ }
+
+ function executeStatement($stmt)
+ {
+ return (bool) $this->execute($stmt->getSQL());
+ }
+
+ function beginTransaction()
+ {
+ $this->execute('BEGIN');
+ }
+
+ function commitTransaction()
+ {
+ $this->execute('COMMIT');
+ }
+
+ function rollbackTransaction()
+ {
+ $this->execute('ROLLBACK');
+ }
+
+ function newStatement($sql)
+ {
+ if(preg_match('/^\s*\(*\s*(\w+).*$/m', $sql, $match))
+ {
+ $statement = $match[1];
+ }
+ else
+ {
+ $statement = $sql;
+ }
+ switch(strtoupper($statement))
+ {
+ case 'SELECT':
+ case 'SHOW':
+ case 'DESCRIBE':
+ case 'EXPLAIN':
+ return new lmbMysqliQueryStatement($this, $sql);
+ case 'INSERT':
+ return new lmbMysqliInsertStatement($this, $sql);
+ case 'UPDATE':
+ case 'DELETE':
+ return new lmbMysqliManipulationStatement($this, $sql);
+ default:
+ return new lmbMysqliStatement($this, $sql);
+ }
+ }
+
+ function getTypeInfo()
+ {
+ return new lmbMysqliTypeInfo();
+ }
+
+
+ function getDatabaseInfo()
+ {
+ return new lmbMysqliDbInfo($this, $this->config['database'], true);
+ }
+
+ function quoteIdentifier($id)
+ {
+ if(!$id)
+ return '';
+
+ $pieces = explode('.', $id);
+ $quoted = '`' . $pieces[0] . '`';
+ if(isset($pieces[1]))
+ $quoted .= '.`' . $pieces[1] . '`';
+ return $quoted;
+ }
+
+ function escape($string)
+ {
+ return mysqli_escape_string($string);
+ }
+
+ function getSequenceValue($table, $colname)
+ {
+ return mysqli_insert_id($this->connectionId);//???
+
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliDbInfo.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliDbInfo.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliDbInfo.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,64 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+lmb_require('limb/dbal/src/drivers/lmbDbInfo.class.php');
+lmb_require('limb/dbal/src/drivers/mysqli/lmbMysqliTableInfo.class.php');
+
+/**
+ * class lmbMysqliDbInfo.
+ *
+ * @package dbal
+ * @version $Id: lmbMysqliDbInfo.class.php 6243 2007-08-29 11:53:10Z pachanga $
+ */
+class lmbMysqliDbInfo extends lmbDbInfo
+{
+ protected $connection;
+ protected $isExisting = false;
+ protected $isTablesLoaded = false;
+
+ function __construct($connection, $name, $isExisting = false)
+ {
+ $this->connection = $connection;
+ $this->isExisting = $isExisting;
+ parent::__construct($name);
+ }
+
+ function getConnection()
+ {
+ return $this->connection;
+ }
+
+ function loadTables()
+ {
+ if($this->isExisting && !$this->isTablesLoaded)
+ {
+ $queryId = $this->connection->execute("SHOW TABLES FROM `" . $this->name . "`");
+ while(is_array($row = Mysqli_fetch_row($queryId)))
+ {
+ $this->tables[$row[0]] = null;
+ }
+ Mysqli_free_result($queryId);
+ $this->isTablesLoaded = true;
+ }
+ }
+
+ function getTable($name)
+ {
+ if(!$this->hasTable($name))
+ {
+ throw new lmbDbException("Table does not exist '$name'");
+ }
+ if(is_null($this->tables[$name]))
+ {
+ $this->tables[$name] = new lmbMysqliTableInfo($this, $name, true);
+ }
+ return $this->tables[$name];
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliInsertStatement.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliInsertStatement.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliInsertStatement.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,31 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+lmb_require('limb/dbal/src/drivers/lmbDbInsertStatement.interface.php');
+lmb_require(dirname(__FILE__) . '/lmbMysqliManipulationStatement.class.php');
+
+/**
+ * class lmbMysqliInsertStatement.
+ *
+ * @package dbal
+ * @version $Id: lmbMysqliInsertStatement.class.php 6243 2007-08-29 11:53:10Z pachanga $
+ */
+class lmbMysqliInsertStatement extends lmbMysqliManipulationStatement implements lmbDbInsertStatement
+{
+ function insertId($field_name = 'id')
+ {
+ $this->execute();
+
+ if(isset($this->parameters[$field_name]) && !empty($this->parameters[$field_name]))
+ return $this->parameters[$field_name];
+ else
+ return $this->connection->getSequenceValue(null, null);
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliManipulationStatement.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliManipulationStatement.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliManipulationStatement.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,27 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/dbal/src/drivers/lmbDbManipulationStatement.interface.php');
+lmb_require(dirname(__FILE__) . '/lmbMysqliStatement.class.php');
+
+/**
+ * class lmbMysqliManipulationStatement.
+ *
+ * @package dbal
+ * @version $Id: lmbMysqliManipulationStatement.class.php 6243 2007-08-29 11:53:10Z pachanga $
+ */
+class lmbMysqliManipulationStatement extends lmbMysqliStatement implements lmbDbManipulationStatement
+{
+ function getAffectedRowCount()
+ {
+ return Mysqli_affected_rows($this->connection->getConnectionId());
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliQueryStatement.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliQueryStatement.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliQueryStatement.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,59 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/dbal/src/drivers/lmbDbQueryStatement.interface.php');
+lmb_require(dirname(__FILE__) . '/lmbMysqliStatement.class.php');
+lmb_require(dirname(__FILE__) . '/lmbMysqliRecord.class.php');
+lmb_require(dirname(__FILE__) . '/lmbMysqliRecordSet.class.php');
+
+/**
+ * class lmbMysqliQueryStatement.
+ *
+ * @package dbal
+ * @version $Id: lmbMysqliQueryStatement.class.php 6243 2007-08-29 11:53:10Z pachanga $
+ */
+class lmbMysqliQueryStatement extends lmbMysqliStatement implements lmbDbQueryStatement
+{
+ function getOneRecord()
+ {
+ $record = new lmbMysqliRecord();
+ $queryId = $this->connection->execute($this->getSQL());
+ $values = Mysqli_fetch_assoc($queryId);
+ $record->import($values);
+ Mysqli_free_result($queryId);
+ if(is_array($values))
+ return $record;
+ }
+
+ function getOneValue()
+ {
+ $queryId = $this->connection->execute($this->getSQL());
+ $row = Mysqli_fetch_row($queryId);
+ Mysqli_free_result($queryId);
+ if(is_array($row))
+ return $row[0];
+ }
+
+ function getOneColumnAsArray()
+ {
+ $column = array();
+ $queryId = $this->connection->execute($this->getSQL());
+ while(is_array($row = Mysqli_fetch_row($queryId)))
+ $column[] = $row[0];
+ Mysqli_free_result($queryId);
+ return $column;
+ }
+
+ function getRecordSet()
+ {
+ return new lmbMysqliRecordSet($this->connection, $this->getSQL());
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliRecord.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliRecord.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliRecord.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,149 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+lmb_require('limb/dbal/src/drivers/lmbDbBaseRecord.class.php');
+
+/**
+ * class lmbMysqliRecord.
+ *
+ * @package dbal
+ * @version $Id: lmbMysqliRecord.class.php 6844 2008-03-18 17:10:33Z pachanga $
+ */
+class lmbMysqliRecord extends lmbDbBaseRecord
+{
+ protected $properties = array();
+
+ function __construct($data = array())
+ {
+ $this->properties = $data;
+ }
+
+ function get($name, $default = LIMB_UNDEFINED)
+ {
+ if(isset($this->properties[$name]))
+ return $this->properties[$name];
+
+ if(LIMB_UNDEFINED !== $default)
+ return $default;
+ }
+
+ function set($name, $value)
+ {
+ $this->properties[$name] = $value;
+ }
+
+ function export()
+ {
+ return $this->properties;
+ }
+
+ function import($values)
+ {
+ $this->properties = $values;
+ }
+
+ function remove($name)
+ {
+ if(isset($this->properties[$name]))
+ unset($this->properties[$name]);
+ }
+
+ function has($name)
+ {
+ return isset($this->properties[$name]);
+ }
+
+ function reset()
+ {
+ $this->properties = array();
+ }
+
+ function getInteger($name)
+ {
+ $value = $this->get($name);
+ return is_null($value) ? null : (int) $value;
+ }
+
+ function getFloat($name)
+ {
+ $value = $this->get($name);
+ return is_null($value) ? null : (float) $value;
+ }
+
+ function getString($name)
+ {
+ $value = $this->get($name);
+ return is_null($value) ? null : (string) $value;
+ }
+
+ function getBoolean($name)
+ {
+ $value = $this->get($name);
+ return is_null($value) ? null : (boolean) $value;
+ }
+
+ function getIntegerTimeStamp($name)
+ {
+ $value = $this->get($name);
+ if(is_integer($value))
+ return $value;
+ else if(is_string($value))
+ {
+ $ts = strtotime($value);
+ if($ts === -1)
+ {
+ if(preg_match('/([\d]{4})([\d]{2})([\d]{2})([\d]{2})([\d]{2})([\d]{2})/', $value, $matches))
+ return mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
+ }
+ else
+ return $ts;
+ }
+ }
+
+ function _getDate($name, $format)
+ {
+ $value = $this->get($name);
+ if(is_integer($value))
+ return date($format, $value);
+ else
+ return $value;
+ }
+
+ function getStringDate($name)
+ {
+ return $this->_getDate($name, 'Y-m-d');
+ }
+
+ function getStringTime($name)
+ {
+ return $this->_getDate($name, 'H:i:s');
+ }
+
+ function getStringTimeStamp($name)
+ {
+ return $this->_getDate($name, 'Y-m-d H:i:s');
+ }
+
+ function getStringFixed($name)
+ {
+ $value = $this->get($name);
+ return is_null($value) ? null : (string) $value;
+ }
+
+ function getBlob($name)
+ {
+ return $this->get($name);
+ }
+
+ function getClob($name)
+ {
+ return $this->get($name);
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliRecordSet.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliRecordSet.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliRecordSet.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,164 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+lmb_require('limb/dbal/src/drivers/lmbDbBaseRecordSet.class.php');
+lmb_require('limb/dbal/src/drivers/mysqli/lmbMysqliRecord.class.php');
+
+/**
+ * class lmbMysqliRecordSet.
+ *
+ * @package dbal
+ * @version $Id: lmbMysqliRecordSet.class.php 6891 2008-04-01 21:44:38Z pachanga $
+ */
+class lmbMysqliRecordSet extends lmbDbBaseRecordSet
+{
+ protected $query;
+ protected $connection;
+
+ protected $current;
+ protected $valid;
+ protected $key;
+
+ function __construct($connection, $queryString)
+ {
+ $this->connection = $connection;
+ $this->query = $queryString;
+ }
+
+ protected function _is_resource($res)
+ {
+ return ('mysqli_result' === get_class($res));
+
+ }
+
+ function freeQuery()
+ {
+ if(isset($this->queryId) && $this->_is_resource($this->queryId))
+ {
+ Mysqli_free_result($this->queryId);
+ $this->queryId = null;
+ }
+ }
+
+ function rewind()
+ {
+ if(isset($this->queryId) && $this->_is_resource($this->queryId) && mysqli_num_rows($this->queryId))
+ {
+ if(mysqli_data_seek($this->queryId, 0) === false)
+ {
+ $this->connection->_raiseError();
+ }
+ }
+ elseif(!$this->queryId)
+ {
+ $query = $this->query;
+
+ if(is_array($this->sort_params))
+ {
+ if(preg_match('~(?<=FROM).+\s+ORDER\s+BY\s+~i', $query))
+ $query .= ',';
+ else
+ $query .= ' ORDER BY ';
+ foreach($this->sort_params as $field => $order)
+ $query .= $this->connection->quoteIdentifier($field) . " $order,";
+
+ $query = rtrim($query, ',');
+ }
+
+ if($this->limit)
+ {
+ $query .= ' LIMIT ' .
+ $this->offset . ',' .
+ $this->limit;
+ }
+
+ $this->queryId = $this->connection->execute($query);
+ }
+ $this->key = 0;
+ $this->next();
+ }
+
+ function next()
+ {
+ $this->current = new lmbMysqliRecord();
+ $values = Mysqli_fetch_assoc($this->queryId);
+ $this->current->import($values);
+ $this->valid = is_array($values);
+ $this->key++;
+ }
+
+ function valid()
+ {
+ return $this->valid;
+ }
+
+ function current()
+ {
+ return $this->current;
+ }
+
+ function key()
+ {
+ return $this->key;
+ }
+
+ function at($pos)
+ {
+ $query = $this->query;
+
+ if(is_array($this->sort_params))
+ {
+ $query .= ' ORDER BY ';
+ foreach($this->sort_params as $field => $order)
+ $query .= $this->connection->quoteIdentifier($field) . " $order,";
+ $query = rtrim($query, ',');
+ }
+
+ $queryId = $this->connection->execute($query . " LIMIT $pos, 1");
+
+ $res = Mysqli_fetch_assoc($queryId);
+ Mysqli_free_result($queryId);
+ if($res)
+ {
+ $record = new lmbMysqliRecord();
+ $record->import($res);
+ return $record;
+ }
+ }
+
+ function countPaginated()
+ {
+ if(is_null($this->queryId))
+ $this->rewind();
+ return Mysqli_num_rows($this->queryId);
+ }
+
+ function count()
+ {
+ if(!(preg_match("/^\s*SELECT\s+DISTINCT/is", $this->query) || preg_match('/\s+GROUP\s+BY\s+/is', $this->query)) &&
+ preg_match("/^\s*SELECT\s+.+\s+FROM\s+/Uis", $this->query))
+ {
+ $rewritesql = preg_replace('/^\s*SELECT\s.*\s+FROM\s/Uis','SELECT COUNT(*) FROM ', $this->query);
+ $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','', $rewritesql);
+
+ $queryId = $this->connection->execute($rewritesql);
+ $row = Mysqli_fetch_row($queryId);
+ Mysqli_free_result($queryId);
+ if(is_array($row))
+ return $row[0];
+ }
+
+ // could not re-write the query, try a different method.
+ $queryId = $this->connection->execute($this->query);
+ $count = Mysqli_num_rows($queryId);
+ Mysqli_free_result($queryId);
+ return $count;
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliStatement.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliStatement.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliStatement.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,204 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+lmb_require('limb/dbal/src/drivers/lmbDbStatement.interface.php');
+
+/**
+ * class lmbMysqliStatement.
+ *
+ * @package dbal
+ * @version $Id: lmbMysqliStatement.class.php 6848 2008-03-21 13:44:08Z svk $
+ */
+class lmbMysqliStatement implements lmbDbStatement
+{
+ protected $statement;
+ protected $connection;
+ protected $parameters = array();
+
+ function __construct($connection, $sql)
+ {
+ $this->statement = $sql;
+ $this->connection = $connection;
+ }
+
+ function setConnection($connection)
+ {
+ $this->connection = $connection;
+ }
+
+ function setNull($name)
+ {
+ $this->parameters[$name] = 'null';
+ }
+
+ function setSmallInt($name, $value)
+ {
+ $this->parameters[$name] = is_null($value) ? 'null' : intval($value);
+ }
+
+ function setInteger($name, $value)
+ {
+ $this->parameters[$name] = is_null($value) ? 'null' : intval($value);
+ }
+
+ function setFloat($name, $value)
+ {
+ $this->parameters[$name] = is_null($value) ?
+ 'null' :
+ floatval($value);
+ }
+
+ function setDouble($name, $value)
+ {
+ if(is_float($value) || is_integer($value))
+ {
+ $this->parameters[$name] = $value;
+ }
+ else if(is_string($value) && preg_match('/^(|-)\d+(|.\d+)$/', $value))
+ {
+ $this->parameters[$name] = $value;
+ }
+ else
+ {
+ $this->parameters[$name] = 'null';
+ }
+ }
+
+ function setDecimal($name, $value)
+ {
+ if(is_float($value) || is_integer($value))
+ {
+ $this->parameters[$name] = $value;
+ }
+ else if(is_string($value) && preg_match('/^(|-)\d+(|.\d+)$/', $value))
+ {
+ $this->parameters[$name] = $value;
+ }
+ else
+ {
+ $this->parameters[$name] = 'null';
+ }
+ }
+
+ function setBoolean($name, $value)
+ {
+ $this->parameters[$name] = is_null($value) ?
+ 'null' :(($value) ? '1' : '0');
+ }
+
+ function setChar($name, $value)
+ {
+ $this->parameters[$name] = is_null($value) ?
+ 'null' :
+ "'" . $this->_escape_string((string) $value) . "'";
+ }
+
+ function setVarChar($name, $value)
+ {
+ $this->parameters[$name] = is_null($value) ?
+ 'null' :
+ "'" . mysqli_real_escape_string($this->connection->getConnectionId(), (string) $value) . "'";
+ }
+
+ function setClob($name, $value)
+ {
+ $this->parameters[$name] = is_null($value) ?
+ 'null' :
+ "'" . mysqli_real_escape_string((string) $value) . "'";
+ }
+
+ protected function _escape_string($string)
+ {
+ return mysqli_real_escape_string($this->connection->getConnectionId(), $string);
+ }
+
+ protected function _setDate($name, $value, $format)
+ {
+ if(is_int($value))
+ {
+ $this->parameters[$name] = "'" . date($format, $value) . "'";
+ }
+ else if(is_string($value))
+ {
+ $this->parameters[$name] = "'" . $this->_escape_string((string) $value) . "'";
+ }
+ else
+ {
+ $this->parameters[$name] = 'null';
+ }
+ }
+
+ function setDate($name, $value)
+ {
+ $this->_setDate($name, $value, 'Y-m-d');
+ }
+
+ function setTime($name, $value)
+ {
+ $this->_setDate($name, $value, 'H:i:s');
+ }
+
+ function setTimeStamp($name, $value)
+ {
+ $this->_setDate($name, $value, 'Y-m-d H:i:s');
+ }
+
+ function setBlob($name, $value)
+ {
+ $this->setChar($name, $value);
+ }
+
+ function set($name, $value)
+ {
+ if(is_string($value))
+ {
+ $this->setChar($name, $value);
+ }
+ else if(is_int($value))
+ {
+ $this->setInteger($name, $value);
+ }
+ else if(is_bool($value))
+ {
+ $this->setBoolean($name, $value);
+ }
+ else if(is_float($value))
+ {
+ $this->setFloat($name, $value);
+ }
+ else
+ {
+ $this->setNull($name);
+ }
+ }
+
+ function import($paramList)
+ {
+ foreach($paramList as $name=>$value)
+ {
+ $this->set($name, $value);
+ }
+ }
+
+ function getSQL()
+ {
+ $sql = $this->statement;
+ foreach($this->parameters as $key => $value)
+ {
+ $sql = str_replace(':' . $key . ':', $value, $sql);
+ }
+ return $sql;
+ }
+
+ function execute()
+ {
+ return $this->connection->executeStatement($this);
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliTableInfo.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliTableInfo.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliTableInfo.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,89 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+lmb_require('limb/dbal/src/drivers/lmbDbTableInfo.class.php');
+lmb_require('limb/dbal/src/drivers/mysqli/lmbMysqliColumnInfo.class.php');
+
+/**
+ * class lmbMysqliTableInfo.
+ *
+ * @package dbal
+ * @version $Id: lmbMysqliTableInfo.class.php 6243 2007-08-29 11:53:10Z pachanga $
+ */
+class lmbMysqliTableInfo extends lmbDbTableInfo
+{
+ protected $isExisting = false;
+ protected $isColumnsLoaded = false;
+ protected $database;
+
+ function __construct($database, $name, $isExisting = false)
+ {
+ parent::__construct($name);
+ $this->database = $database;
+ $this->isExisting = $isExisting;
+ }
+
+ function getDatabase()
+ {
+ return $this->database;
+ }
+
+ //Based on code from Creole
+ function loadColumns()
+ {
+ if($this->isExisting && !$this->isColumnsLoaded)
+ {
+ $connection = $this->database->getConnection();
+ $queryId = $connection->execute("SHOW COLUMNS FROM `" . $this->name . "`");
+
+ while($row = Mysqli_fetch_assoc($queryId))
+ {
+ $name = $row['Field'];
+ $isNullable =($row['Null'] == 'YES');
+ $isAutoIncrement =(strpos($row['Extra'], 'auto_increment') !== false);
+ $size = null;
+ $precision = null;
+
+ if(preg_match('/^(\w+)[\(]?([\d,]*)[\)]?( |$)/', $row['Type'], $matches))
+ {
+ // colname[1] size/precision[2]
+ $nativeType = $matches[1];
+ if($matches[2])
+ {
+ if(($cpos = strpos($matches[2], ',')) !== false)
+ {
+ $size = (int) substr($matches[2], 0, $cpos);
+ $precision = (int) substr($matches[2], $cpos + 1);
+ }
+ else
+ {
+ $size = (int) $matches[2];
+ }
+ }
+ }
+ elseif(preg_match('/^(\w+)\(/', $row['Type'], $matches))
+ {
+ $nativeType = $matches[1];
+ }
+ else
+ {
+ $nativeType = $row['Type'];
+ }
+
+ // BLOBs can't have any default values in Mysqli
+ $default = preg_match('~blob|text~', $nativeType) ? null : $row['Default'];
+
+ $this->columns[$name] = new lmbMysqliColumnInfo($this,
+ $name, $nativeType, $size, $precision, $isNullable, $default, $isAutoIncrement);
+ }
+ $this->isColumnsLoaded = true;
+ }
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliTypeInfo.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliTypeInfo.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/src/drivers/mysqli/lmbMysqliTypeInfo.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,55 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/dbal/src/drivers/lmbDbTypeInfo.class.php');
+
+/**
+ * class lmbMysqliTypeInfo.
+ *
+ * @package dbal
+ * @version $Id: lmbMysqliTypeInfo.class.php 6243 2007-08-29 11:53:10Z pachanga $
+ */
+class lmbMysqliTypeInfo extends lmbDbTypeInfo
+{
+ function getNativeToColumnTypeMapping()
+ {
+ return array(
+ 'tinyint' => LIMB_DB_TYPE_SMALLINT,
+ 'smallint' => LIMB_DB_TYPE_SMALLINT,
+ 'mediumint' => LIMB_DB_TYPE_INTEGER,
+ 'int' => LIMB_DB_TYPE_INTEGER,
+ 'integer' => LIMB_DB_TYPE_INTEGER,
+ 'bigint' => LIMB_DB_TYPE_DECIMAL,
+ 'int24' => LIMB_DB_TYPE_INTEGER,
+ 'real' => LIMB_DB_TYPE_FLOAT,
+ 'float' => LIMB_DB_TYPE_FLOAT,
+ 'decimal' => LIMB_DB_TYPE_DECIMAL,
+ 'numeric' => LIMB_DB_TYPE_DECIMAL,
+ 'double' => LIMB_DB_TYPE_DOUBLE,
+ 'char' => LIMB_DB_TYPE_CHAR,
+ 'varchar' => LIMB_DB_TYPE_VARCHAR,
+ 'date' => LIMB_DB_TYPE_DATE,
+ 'time' => LIMB_DB_TYPE_TIME,
+ 'year' => LIMB_DB_TYPE_INTEGER,
+ 'datetime' => LIMB_DB_TYPE_TIMESTAMP,
+ 'timestamp' => LIMB_DB_TYPE_TIMESTAMP,
+ 'tinyblob' => LIMB_DB_TYPE_BLOB,
+ 'blob' => LIMB_DB_TYPE_BLOB,
+ 'mediumblob' => LIMB_DB_TYPE_BLOB,
+ 'longblob' => LIMB_DB_TYPE_BLOB,
+ 'tinytext' => LIMB_DB_TYPE_CLOB,
+ 'mediumtext' => LIMB_DB_TYPE_CLOB,
+ 'text' => LIMB_DB_TYPE_CLOB,
+ 'longtext' => LIMB_DB_TYPE_CLOB,
+ 'enum' => LIMB_DB_TYPE_CHAR,
+ 'set' => LIMB_DB_TYPE_CHAR,
+ );
+ }
+}
+
Added: 3.x/trunk/limb/dbal/src/dump/lmbMysqliDumpLoader.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/dump/lmbMysqliDumpLoader.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/src/dump/lmbMysqliDumpLoader.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,174 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+lmb_require('limb/dbal/src/dump/lmbSQLDumpLoader.class.php');
+
+/**
+ * class lmbMysqlDumpLoader.
+ *
+ * @package dbal
+ * @version $Id: lmbMysqlDumpLoader.class.php 6243 2007-08-29 11:53:10Z pachanga $
+ */
+class lmbMysqlDumpLoader extends lmbSQLDumpLoader
+{
+ // the parsing code was taken from somewhere else...
+ // and it's ugly, ugly, ugly!!!
+ // use some sort of lexer later...
+ protected function _retrieveStatements($sql)
+ {
+ $ret = array();
+
+ $sql = trim($sql);
+ $sql_len = strlen($sql);
+ $char = '';
+ $string_start = '';
+ $in_string = false;
+
+ for($i = 0; $i < $sql_len; ++$i)
+ {
+ $char = $sql[$i];
+
+ // We are in a string, check for not escaped end of strings except for
+ // backquotes that can't be escaped
+ if($in_string)
+ {
+ for(;;)
+ {
+ $i = strpos($sql, $string_start, $i);
+ // No end of string found->add the current substring to the
+ // returned array
+ if (!$i)
+ {
+ $ret[] = $sql;
+ return $ret;
+ }
+ // Backquotes or no backslashes before quotes: it's indeed the
+ // end of the string->exit the loop
+ elseif ($string_start == '`' || $sql[$i-1] != '\\')
+ {
+ $string_start = '';
+ $in_string = false;
+ break;
+ }
+ // one or more Backslashes before the presumed end of string...
+ else
+ {
+ // ... first checks for escaped backslashes
+ $j = 2;
+ $escaped_backslash = false;
+ while ($i-$j > 0 && $sql[$i-$j] == '\\')
+ {
+ $escaped_backslash = !$escaped_backslash;
+ $j++;
+ }
+ // ... if escaped backslashes: it's really the end of the
+ // string->exit the loop
+ if ($escaped_backslash)
+ {
+ $string_start = '';
+ $in_string = false;
+ break;
+ }
+ else
+ $i++;
+ }
+ }
+ }
+ // We are not in a string, first check for delimiter...
+ elseif($char == ';')
+ {
+ // if delimiter found, add the parsed part to the returned array
+ $ret[] = substr($sql, 0, $i);
+ $sql = ltrim(substr($sql, min($i + 1, $sql_len)));
+ $sql_len = strlen($sql);
+ if($sql_len)
+ $i = -1;
+ else
+ return $ret;
+ }
+ // ... then check for start of a string,...
+ elseif (($char == '"') || ($char == '\'') || ($char == '`'))
+ {
+ $in_string = true;
+ $string_start = $char;
+ }
+ // ... for start of a comment (and remove this comment if found)...
+ elseif ($char == '#'
+ || ($char == ' ' && $i > 1 && $sql[$i-2] . $sql[$i-1] == '--'))
+ {
+ // starting position of the comment depends on the comment type
+ $start_of_comment = (($sql[$i] == '#') ? $i : $i-2);
+ $end_of_comment = self :: _getEndOfCommentPosition($sql, $i+2);
+
+ if(!$end_of_comment)
+ {
+ // no eol found after '#', add the parsed part to the returned
+ // array if required and exit
+ if($start_of_comment > 0)
+ $ret[] = trim(substr($sql, 0, $start_of_comment));
+
+ return $ret;
+ }
+ else
+ {
+ $sql = substr($sql, 0, $start_of_comment) . ltrim(substr($sql, $end_of_comment));
+ $sql_len = strlen($sql);
+ $i--;
+ }
+ }
+ // ... for start of a comment /* and remove it
+ elseif($char == '/' && isset($sql[$i+1]) && $sql[$i+1] == '*')
+ {
+ $start_of_comment = $i;
+ $end_of_comment = self :: _getEndOfCommentPosition($sql, $i+2);
+
+ if(!$end_of_comment)
+ {
+ // no eol found after '#', add the parsed part to the returned
+ // array if required and exit
+ if($start_of_comment > 0)
+ $ret[] = trim(substr($sql, 0, $start_of_comment));
+
+ return $ret;
+ }
+ else
+ {
+ $sql = substr($sql, 0, $start_of_comment) . ltrim(substr($sql, $end_of_comment));
+ $sql_len = strlen($sql);
+ $i--;
+ }
+ }
+ }
+ // add any rest to the returned array
+ if (!empty($sql) && preg_match('/\S+/', $sql))
+ $ret[] = $sql;
+
+ return $ret;
+ }
+
+ protected function _getEndOfCommentPosition($str, $start)
+ {
+ // if no "\n" exits in the remaining string, checks for "\r"
+ // (Mac eol style)
+
+ if($pos = strpos(' ' . $str, "*/\012", $start))
+ return $pos;
+ if($pos = strpos(' ' . $str, "*/\015", $start))
+ return $pos;
+ if($pos = strpos(' ' . $str, "*/;", $start))
+ return $pos+1;
+
+ return false;
+ }
+
+ protected function _processTableName($table)
+ {
+ return trim($table, '`');
+ }
+}
+
Added: 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/.skipif.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/.skipif.php (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/.skipif.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,12 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+require_once('limb/dbal/common.inc.php');
+//return lmbToolkit :: instance()->getDefaultDbConnection()->getType() != 'mysqli';
+return false;
+
Added: 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/fixture.inc.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/fixture.inc.php (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/fixture.inc.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,61 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+error_reporting(E_ALL);
+
+function DriverMysqliSetup($conn)
+{
+ DriverMysqliExec($conn, 'DROP TABLE IF EXISTS founding_fathers;');
+ $sql = "CREATE TABLE founding_fathers (
+ id int(11) NOT null auto_increment,
+ first varchar(50) NOT null default '',
+ last varchar(50) NOT null default '',
+ PRIMARY KEY (id)) AUTO_INCREMENT=4 TYPE=InnoDB";
+ DriverMysqliExec($conn, $sql);
+
+ DriverMysqliExec($conn, 'DROP TABLE IF EXISTS standard_types');
+ $sql = "
+ CREATE TABLE standard_types (
+ id int(11) NOT null auto_increment,
+ type_smallint smallint,
+ type_integer integer,
+ type_boolean smallint,
+ type_char char (30),
+ type_varchar varchar (30),
+ type_clob text,
+ type_float float,
+ type_double double,
+ type_decimal decimal (30, 2),
+ type_timestamp datetime,
+ type_date date,
+ type_time time,
+ type_blob blob,
+ PRIMARY KEY (id)) AUTO_INCREMENT=4";
+ DriverMysqliExec($conn, $sql);
+
+ DriverMysqliExec($conn, 'TRUNCATE founding_fathers');
+ DriverMysqliExec($conn, 'TRUNCATE standard_types');
+
+ $inserts = array(
+ "INSERT INTO founding_fathers VALUES (1, 'George', 'Washington');",
+ "INSERT INTO founding_fathers VALUES (2, 'Alexander', 'Hamilton');",
+ "INSERT INTO founding_fathers VALUES (3, 'Benjamin', 'Franklin');"
+ );
+
+ foreach($inserts as $sql)
+ DriverMysqliExec($conn, $sql);
+}
+
+function DriverMysqliExec($conn, $sql)
+{
+// var_dump($sql);
+ $result = mysqli_query($conn, $sql);
+ if(false === $result)
+ throw new lmbDbException('MySQLi execute error happened: ', array('error' => mysqli_error($conn)));
+}
Added: 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliColumnInfoTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliColumnInfoTest.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliColumnInfoTest.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,21 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+require_once(dirname(__FILE__) . '/../DriverColumnInfoTestBase.class.php');
+require_once(dirname(__FILE__) . '/fixture.inc.php');
+
+class lmbMysqliColumnInfoTest extends DriverColumnInfoTestBase
+{
+
+ function setUp()
+ {
+ $this->connection = lmbToolkit :: instance()->getDefaultDbConnection();
+ DriverMysqliSetup($this->connection->getConnectionId());
+ parent::setUp();
+ }
+}
Added: 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliConnectionTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliConnectionTest.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliConnectionTest.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,26 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+require_once(dirname(__FILE__) . '/../DriverConnectionTestBase.class.php');
+require_once(dirname(__FILE__) . '/fixture.inc.php');
+
+class lmbMysqliConnectionTest extends DriverConnectionTestBase
+{
+ function lmbMysqliConnectionTest()
+ {
+ parent :: DriverConnectionTestBase('lmbMysqliQueryStatement', 'lmbMysqliInsertStatement', 'lmbMysqliManipulationStatement', 'lmbMysqliStatement');
+ }
+
+ function setUp()
+ {
+ $this->connection = lmbToolkit :: instance()->getDefaultDbConnection();
+ DriverMysqliSetup($this->connection->getConnectionId());
+ parent::setUp();
+ }
+}
Added: 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliDbInfoTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliDbInfoTest.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliDbInfoTest.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,23 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+require_once(dirname(__FILE__) . '/../DriverDatabaseInfoTestBase.class.php');
+require_once(dirname(__FILE__) . '/fixture.inc.php');
+
+class lmbMysqliDbInfoTest extends DriverDatabaseInfoTestBase
+{
+ function setUp()
+ {
+ $this->connection = lmbToolkit :: instance()->getDefaultDbConnection();
+ DriverMysqliSetup($this->connection->getConnectionId());
+ parent::setUp();
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliDeleteTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliDeleteTest.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliDeleteTest.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,23 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+require_once(dirname(__FILE__) . '/../DriverDeleteTestBase.class.php');
+require_once(dirname(__FILE__) . '/fixture.inc.php');
+
+class lmbMysqliDeleteTest extends DriverDeleteTestBase
+{
+ function setUp()
+ {
+ $this->connection = lmbToolkit :: instance()->getDefaultDbConnection();
+ DriverMysqliSetup($this->connection->getConnectionId());
+ parent::setUp();
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliDriverTransactionTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliDriverTransactionTest.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliDriverTransactionTest.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,23 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+require_once(dirname(__FILE__) . '/../DriverTransactionTestBase.class.php');
+require_once(dirname(__FILE__) . '/fixture.inc.php');
+
+class lmbMysqliDriverTransactionTest extends DriverTransactionTestBase
+{
+ function setUp()
+ {
+ $this->connection = lmbToolkit :: instance()->getDefaultDbConnection();
+ DriverMysqliSetup($this->connection->getConnectionId());
+ parent::setUp();
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliInsertTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliInsertTest.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliInsertTest.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,29 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+require_once(dirname(__FILE__) . '/../DriverInsertTestBase.class.php');
+require_once(dirname(__FILE__) . '/fixture.inc.php');
+
+class lmbMysqliInsertTest extends DriverInsertTestBase
+{
+
+ function lmbMysqliInsertTest()
+ {
+ parent :: DriverInsertTestBase('lmbMysqliInsertStatement');
+ }
+
+ function setUp()
+ {
+ $this->connection = lmbToolkit :: instance()->getDefaultDbConnection();
+ DriverMysqliSetup($this->connection->getConnectionId());
+ parent::setUp();
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliQueryTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliQueryTest.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliQueryTest.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,29 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+require_once(dirname(__FILE__) . '/../DriverQueryTestBase.class.php');
+require_once(dirname(__FILE__) . '/fixture.inc.php');
+
+class lmbMysqliQueryTest extends DriverQueryTestBase
+{
+
+ function lmbMysqliQueryTest()
+ {
+ parent :: DriverQueryTestBase('lmbMysqliRecord');
+ }
+
+ function setUp()
+ {
+ $this->connection = lmbToolkit :: instance()->getDefaultDbConnection();
+ DriverMysqliSetup($this->connection->getConnectionId());
+ parent::setUp();
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliRecordSetTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliRecordSetTest.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliRecordSetTest.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,28 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+require_once(dirname(__FILE__) . '/../DriverRecordSetTestBase.class.php');
+require_once(dirname(__FILE__) . '/fixture.inc.php');
+
+class lmbMysqliRecordSetTest extends DriverRecordSetTestBase
+{
+ function lmbMysqliRecordSetTest()
+ {
+ parent :: DriverRecordSetTestBase('lmbMysqliRecord');
+ }
+
+ function setUp()
+ {
+ $this->connection = lmbToolkit :: instance()->getDefaultDbConnection();
+ DriverMysqliSetup($this->connection->getConnectionId());
+ parent::setUp();
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliRecordTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliRecordTest.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliRecordTest.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,28 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+require_once(dirname(__FILE__) . '/../DriverRecordTestBase.class.php');
+require_once(dirname(__FILE__) . '/fixture.inc.php');
+
+class lmbMysqliRecordTest extends DriverRecordTestBase
+{
+ function __construct()
+ {
+ parent :: __construct('lmbMysqliRecord');
+ }
+
+ function setUp()
+ {
+ $this->connection = lmbToolkit :: instance()->getDefaultDbConnection();
+ DriverMysqliSetup($this->connection->getConnectionId());
+ parent::setUp();
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliStatementTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliStatementTest.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliStatementTest.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,22 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+require_once(dirname(__FILE__) . '/../DriverStatementTestBase.class.php');
+require_once(dirname(__FILE__) . '/fixture.inc.php');
+
+class lmbMysqliStatementTest extends DriverStatementTestBase
+{
+ function setUp()
+ {
+ $this->connection = lmbToolkit :: instance()->getDefaultDbConnection();
+ DriverMysqliSetup($this->connection->getConnectionId());
+ parent::setUp();
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliTableInfoTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliTableInfoTest.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliTableInfoTest.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,23 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+require_once(dirname(__FILE__) . '/../DriverTableInfoTestBase.class.php');
+require_once(dirname(__FILE__) . '/fixture.inc.php');
+
+class lmbMysqliTableInfoTest extends DriverTableInfoTestBase
+{
+ function setUp()
+ {
+ $this->connection = lmbToolkit :: instance()->getDefaultDbConnection();
+ DriverMysqliSetup($this->connection->getConnectionId());
+ parent::setUp();
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliTypeInfoTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliTypeInfoTest.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliTypeInfoTest.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,29 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+require_once(dirname(__FILE__) . '/../DriverTypeInfoTestBase.class.php');
+require_once(dirname(__FILE__) . '/fixture.inc.php');
+
+class lmbMysqliTypeInfoTest extends DriverTypeInfoTestBase
+{
+
+ function lmbMysqliTypeInfoTest()
+ {
+ parent :: DriverTypeInfoTestBase('lmbMysqliStatement', 'lmbMysqliRecord');
+ }
+
+ function setUp()
+ {
+ $this->connection = lmbToolkit :: instance()->getDefaultDbConnection();
+ $this->typeInfo = $this->connection->getTypeInfo();
+ parent::setUp();
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliUpdateTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliUpdateTest.class.php (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/mysqli/lmbMysqliUpdateTest.class.php 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,29 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+require_once(dirname(__FILE__) . '/../DriverUpdateTestBase.class.php');
+require_once(dirname(__FILE__) . '/fixture.inc.php');
+
+class lmbMysqliUpdateTest extends DriverUpdateTestBase
+{
+
+ function lmbMysqliUpdateTest()
+ {
+ parent :: DriverUpdateTestBase('lmbMysqliManipulationStatement');
+ }
+
+ function setUp()
+ {
+ $this->connection = lmbToolkit :: instance()->getDefaultDbConnection();
+ DriverMysqliSetup($this->connection->getConnectionId());
+ parent::setUp();
+ }
+}
+
+
Added: 3.x/trunk/limb/dbal/tests/cases/non-driver/.fixture/init_tests.mysqli
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/non-driver/.fixture/init_tests.mysqli (rev 0)
+++ 3.x/trunk/limb/dbal/tests/cases/non-driver/.fixture/init_tests.mysqli 2008-04-10 12:57:30 UTC (rev 6911)
@@ -0,0 +1,34 @@
+DROP TABLE IF EXISTS `test_one_table_object`;
+CREATE TABLE `test_one_table_object` (
+ `id` bigint(20) NOT NULL auto_increment,
+ `annotation` text,
+ `content` text,
+ `news_date` date default NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+DROP TABLE IF EXISTS `test_db_table`;
+CREATE TABLE `test_db_table` (
+ `id` int(11) unsigned NOT NULL auto_increment,
+ `description` text,
+ `title` varchar(255) NOT NULL default '',
+ `ordr` int(11) NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+DROP TABLE IF EXISTS `all_types_test`;
+CREATE TABLE `all_types_test` (
+ `field_int` int(11) default NULL,
+ `field_varchar` varchar(255) default NULL,
+ `field_char` varchar(11) default NULL,
+ `field_date` date default NULL,
+ `field_datetime` datetime default NULL,
+ `field_time` time default NULL,
+ `field_text` text,
+ `field_smallint` smallint(6) default NULL,
+ `field_bigint` bigint(20) default NULL,
+ `field_blob` blob,
+ `field_float` float default NULL,
+ `field_decimal` decimal(10,0) default NULL,
+ `field_tinyint` tinyint(4) default NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
More information about the limb-svn
mailing list