diff options
16 files changed, 0 insertions, 2232 deletions
| diff --git a/.gitattributes b/.gitattributes index ca32894f..289f27a2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1629,21 +1629,6 @@ framework/Data/ActiveRecord/TActiveRecordCriteria.php -text  framework/Data/ActiveRecord/TActiveRecordGateway.php -text  framework/Data/ActiveRecord/TActiveRecordManager.php -text  framework/Data/ActiveRecord/TActiveRecordStateRegistry.php -text -framework/Data/ActiveRecord/Vendor/TDbMetaData.php -text -framework/Data/ActiveRecord/Vendor/TDbMetaDataCommon.php -text -framework/Data/ActiveRecord/Vendor/TDbMetaDataInspector.php -text -framework/Data/ActiveRecord/Vendor/TIbmColumnMetaData.php -text -framework/Data/ActiveRecord/Vendor/TIbmMetaData.php -text -framework/Data/ActiveRecord/Vendor/TIbmMetaDataInspector.php -text -framework/Data/ActiveRecord/Vendor/TMysqlColumnMetaData.php -text -framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php -text -framework/Data/ActiveRecord/Vendor/TMysqlMetaDataInspector.php -text -framework/Data/ActiveRecord/Vendor/TPgsqlColumnMetaData.php -text -framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php -text -framework/Data/ActiveRecord/Vendor/TPgsqlMetaDataInspector.php -text -framework/Data/ActiveRecord/Vendor/TSqliteColumnMetaData.php -text -framework/Data/ActiveRecord/Vendor/TSqliteMetaData.php -text -framework/Data/ActiveRecord/Vendor/TSqliteMetaDataInspector.php -text  framework/Data/Common/IbmDb2/TIbmColumnMetaData.php -text  framework/Data/Common/IbmDb2/TIbmMetaData.php -text  framework/Data/Common/IbmDb2/TIbmMetaDataInspector.php -text diff --git a/framework/Data/ActiveRecord/Vendor/TDbMetaData.php b/framework/Data/ActiveRecord/Vendor/TDbMetaData.php deleted file mode 100644 index 8ca65c01..00000000 --- a/framework/Data/ActiveRecord/Vendor/TDbMetaData.php +++ /dev/null @@ -1,387 +0,0 @@ -<?php
 -/**
 - * TDbMetaData class file.
 - *
 - * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 - * @link http://www.pradosoft.com/
 - * @copyright Copyright © 2005-2007 PradoSoft
 - * @license http://www.pradosoft.com/license/
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - */
 -
 -/**
 - * Table meta data for Active Record.
 - *
 - * TDbMetaData is the base class for database vendor specific that builds
 - * the appropriate database commands for active record finder and commit methods.
 - *
 - * @author Wei Zhuo <weizho[at]gmail[dot]com>
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - * @since 3.1
 - */
 -abstract class TDbMetaData extends TComponent
 -{
 -	private $_primaryKeys=array();
 -	private $_foreignKeys=array();
 -
 -	/**
 -	 * @var TMap column meta data.
 -	 */
 -	private $_columns;
 -
 -	private $_table;
 -	private $_isView=false;
 -
 -	/**
 -	 * Initialize the meta data.
 -	 * @param string table name
 -	 * @param array name value pair of column meta data in the table
 -	 * @param array primary key field names
 -	 * @param array foriegn key field meta data.
 -	 */
 -	public function __construct($table, $cols, $pk, $fk=array(),$view=false)
 -	{
 -		$this->_table=$table;
 -		$this->_columns=new TMap($cols);
 -		$this->_primaryKeys=$pk;
 -		$this->_foreignKeys=$fk;
 -		$this->_isView=$view;
 -	}
 -
 -	public function getIsView()
 -	{
 -		return $this->_isView;
 -	}
 -
 -	/**
 -	 * @return string table name
 -	 */
 -	public function getTableName()
 -	{
 -		return $this->_table;
 -	}
 -
 -	/**
 -	 * @return array primary key field names.
 -	 */
 -	public function getPrimaryKeys()
 -	{
 -		return $this->_primaryKeys;
 -	}
 -
 -	/**
 -	 * @return array foreign key meta data.
 -	 */
 -	public function getForeignKeys()
 -	{
 -		return $this->_foreignKeys;
 -	}
 -
 -	/**
 -	 * @return array name value pair column meta data
 -	 */
 -	public function getColumns()
 -	{
 -		return $this->_columns;
 -	}
 -
 -	/**
 -	 * @param unknown_type $name
 -	 */
 -	public function getColumn($name)
 -	{
 -		return $this->_columns[$name];
 -	}
 -
 -	public function getColumnNames()
 -	{
 -		return $this->_columns->getKeys();
 -	}
 -
 -	/**
 -	 * Post process the rows after returning from a 1 row query.
 -	 * @param mixed row data, may be null.
 -	 * @return mixed processed rows.
 -	 */
 -	public function postQueryRow($row)
 -	{
 -		return $row;
 -	}
 -
 -	/**
 -	 * Post process the rows after returning from a 1 row query.
 -	 * @param TDbDataReader multiple row data
 -	 * @return array post processed data.
 -	 */
 -	public function postQuery($rows)
 -	{
 -		return $rows;
 -	}
 -
 -	/**
 -	 * @return string command separated list of all fields in the table, field names are quoted.
 -	 */
 -	protected function getSelectionColumns()
 -	{
 -		$columns = array();
 -		foreach($this->getColumns() as $column)
 -			$columns[] = $column->getName();
 -		return implode(', ', $columns);
 -	}
 -
 -	/**
 -	 * Construct search criteria using primary key names
 -	 * @return string SQL string for used after WHERE statement.
 -	 */
 -	protected function getPrimaryKeyCriteria()
 -	{
 -		if(count($this->getPrimaryKeys())===0)
 -			throw new TActiveRecordException('ar_no_primary_key_found',$this->getTableName());
 -		$criteria=array();
 -		foreach($this->getPrimaryKeys() as $key)
 -			$criteria[] = $this->getColumn($key)->getName(). ' = :'.$key;
 -		return implode(' AND ', $criteria);
 -	}
 -
 -	/**
 -	 * Construct a "pk IN ('key1', 'key2', ...)" criteria.
 -	 * @param TDbConnection database connection.
 -	 * @param array values for IN predicate
 -	 * @param string SQL string for primary keys IN a list.
 -	 */
 -	protected function getCompositeKeysCriteria($conn, $values)
 -	{
 -		$count = count($this->getPrimaryKeys());
 -		if($count===0)
 -			throw new TActiveRecordException('ar_no_primary_key_found',$this->getTableName());
 -		if(!is_array($values) || count($values) === 0)
 -			throw new TActiveRecordException('ar_missing_pk_values', $this->getTableName());
 -		if($count>1 && !is_array($values[0]))
 -			$values = array($values);
 -		if($count > 1 && count($values[0]) !== $count)
 -			throw new TActiveRecordException('ar_pk_value_count_mismatch', $this->getTableName());
 -
 -		$columns = array();
 -		foreach($this->getPrimaryKeys() as $key)
 -			$columns[] = $this->getColumn($key)->getName();
 -		return '('.implode(', ',$columns).') IN '.$this->quoteTuple($conn, $values);
 -	}
 -
 -	/**
 -	 * @param TDbConnection database connection.
 -	 * @param array values
 -	 * @return string quoted recursive tuple values, e.g. "('val1', 'val2')".
 -	 */
 -	protected function quoteTuple($conn, $array)
 -	{
 -		$data = array();
 -		foreach($array as $k=>$v)
 -			$data[] = is_array($v) ? $this->quoteTuple($conn, $v) : $conn->quoteString($v);
 -		return '('.implode(', ', $data).')';
 -	}
 -
 -	/**
 -	 * Bind a list of variables in the command. The named parameters is taken
 -	 * from the values of the $keys parameter. The bind value is taken from the
 -	 * $values parameter using the index taken from the each value of $keys array.
 -	 * @param TDbCommand SQL database command
 -	 * @param array named parameters
 -	 * @param array binding values (index should match that of $keys)
 -	 */
 -	protected function bindArrayKeyValues($command, $keys, $values)
 -	{
 -		if(!is_array($values)) $values = array($values);
 -		foreach($keys as $i => $key)
 -		{
 -			$value = array_key_exists($i,$values) ? $values[$i] : $values[$key];
 -			$this->bindValue($command, ':'.$key, $value);
 -		}
 -		$command->prepare();
 -	}
 -
 -	/**
 -	 * Returns a list of name value pairs from the object.
 -	 * @param array named parameters
 -	 * @param TActiveRecord record object
 -	 * @return array name value pairs.
 -	 */
 -	protected function getObjectKeyValues($keys, $object)
 -	{
 -		$properties = array();
 -		foreach($keys as $key)
 -			$properties[$key] = $object->{$key};
 -		return $properties;
 -	}
 -
 -	/**
 -	 * Gets the columns that can be inserted into the database.
 -	 * Missing properties are assumed to be null.
 -	 * @param TActiveRecord record object to be inserted.
 -	 * @return array name value pairs of fields to be added.
 -	 * @throws TActiveRecordException if property is null and table column is
 -	 * defined as not null unless primary key column.
 -	 */
 -	protected function getInsertableColumns($record)
 -	{
 -		$columns = array();
 -		foreach($this->getColumns() as $name=>$column)
 -		{
 -			try
 -			{
 -				$value = $record->{$name};
 -			}
 -			catch (TInvalidOperationException $e) //ignore missing properties
 -			{
 -				$value = null;
 -			}
 -
 -			if($column->getNotNull() && $value===null && !$column->getIsPrimaryKey())
 -			{
 -				throw new TActiveRecordException(
 -					'ar_value_must_not_be_null', get_class($record),
 -					$this->getTableName(), $name);
 -			}
 -			if($value!==null)
 -				$columns[$name] = $value;
 -		}
 -		return $columns;
 -	}
 -
 -	/**
 -	 * Gets the columns that will be updated, it exculdes primary key columns
 -	 * and record properties that are null.
 -	 * @param TActiveRecord record object with new data for update.
 -	 * @return array name value pairs of fields to be updated.
 -	 */
 -	protected function getUpdatableColumns($record)
 -	{
 -		$columns = array();
 -		foreach($this->getColumns() as $name => $column)
 -		{
 -			$value = $record->{$name};
 -			if(!$column->getIsPrimaryKey() && $value !== null)
 -				$columns[$name] = $value;
 -		}
 -		return $columns;
 -	}
 -
 -	/**
 -	 * Gets a comma delimited string of name parameters for update.
 -	 * @param array name value pairs of columns for update.
 -	 * @return string update named parameter string.
 -	 */
 -	protected function getUpdateBindings($columns)
 -	{
 -		$fields = array();
 -		foreach($columns as $name=>$value)
 -			$fields[] = $this->getColumn($name)->getName(). '= :'.$name;
 -		return implode(', ', $fields);
 -	}
 -
 -	/**
 -	 * Create a new database command based on the given $sql and bind the
 -	 * named parameters given by $names with values corresponding in $values.
 -	 * @param TDbConnection database connection.
 -	 * @param string SQL string.
 -	 * @param array named parameters
 -	 * @param array matching named parameter values
 -	 * @return TDbCommand binded command, ready for execution.
 -	 */
 -	protected function createBindedCommand($conn, $sql, $names,$values)
 -	{
 -		$conn->setActive(true);
 -		$command = $conn->createCommand($sql);
 -		$this->bindArrayKeyValues($command,$names,$values);
 -		return $command;
 -	}
 -
 -	/**
 -	 * Creates a new database command and bind the values from the criteria object.
 -	 *
 -	 * @param TDbConnection database connection.
 -	 * @param string SQL string.
 -	 * @param TActiveRecordCriteria search criteria
 -	 * @return TDbCommand binded command.
 -	 */
 -	protected function createCriteriaBindedCommand($conn,$sql,$criteria)
 -	{
 -		$conn->setActive(true);
 -		$command = $conn->createCommand($sql);
 -		if($criteria!==null)
 -		{
 -			if($criteria->getIsNamedParameters())
 -			{
 -				foreach($criteria->getParameters() as $name=>$value)
 -					$this->bindValue($command, $name, $value);
 -			}
 -			else
 -			{
 -				$index=1;
 -				foreach($criteria->getParameters() as $value)
 -					$this->bindValue($command, $index++,$value);
 -			}
 -		}
 -		$command->prepare();
 -		return $command;
 -	}
 -
 -	protected function bindValue($command, $name, $value)
 -	{
 -		if(is_bool($value))
 -			$command->bindValue($name,$value, PDO::PARAM_BOOL);
 -		else
 -			$command->bindValue($name,$value);
 -	}
 -
 -	/**
 -	 * Bind parameter values.
 -	 */
 -	protected function bindParameterValues($conn,$command,$parameters)
 -	{
 -		$index=1;
 -		foreach($parameters as $key=>$value)
 -		{
 -			if(is_string($key))
 -				$this->bindValue($command,$key,$value);
 -			else
 -				$this->bindValue($command, $index++,$value);
 -		}
 -		$command->prepare();
 -	}
 -
 -	/**
 -	 * Gets the comma delimited string of fields name for insert command.
 -	 */
 -	protected function getInsertColumNames($columns)
 -	{
 -		$fields = array();
 -		foreach($columns as $name=>$column)
 -			$fields[] = $this->getColumn($name)->getName();
 -		return implode(', ', $fields);
 -	}
 -
 -	/**
 -	 * Gets the comma delimited string of name bindings for insert command.
 -	 */
 -	protected function getInsertColumnValues($columns)
 -	{
 -		$fields = array();
 -		foreach(array_keys($columns) as $column)
 -			$fields[] = ':'.$column;
 -		return implode(', ', $fields);
 -	}
 -
 -	/**
 -	 * @param string ordering column name
 -	 * @param string ordering direction
 -	 * @return string DESC or ASC
 -	 */
 -	protected function getOrdering($by, $direction)
 -	{
 -		$dir = strtolower($direction) == 'desc' ? 'DESC' : 'ASC';
 -		return $this->getColumn($by)->getName(). ' '.$dir;
 -	}
 -} -?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Vendor/TDbMetaDataCommon.php b/framework/Data/ActiveRecord/Vendor/TDbMetaDataCommon.php deleted file mode 100644 index a41e87ad..00000000 --- a/framework/Data/ActiveRecord/Vendor/TDbMetaDataCommon.php +++ /dev/null @@ -1,205 +0,0 @@ -<?php -/**
 - * TDbMetaDataCommon class file.
 - *
 - * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 - * @link http://www.pradosoft.com/
 - * @copyright Copyright © 2005-2007 PradoSoft
 - * @license http://www.pradosoft.com/license/
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - */
 -
 -Prado::using('System.Data.ActiveRecord.Vendor.TDbMetaData');
 -
 -/**
 - * Common database command: insert, update, select and delete.
 - *
 - * Base class for database specific insert, update, select and delete command builder.
 - *
 - * @author Wei Zhuo <weizho[at]gmail[dot]com>
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - * @since 3.1
 - */
 -abstract class TDbMetaDataCommon extends TDbMetaData
 -{
 -	/**
 -	 * SQL database command for finding the record by primary keys.
 -	 * @param TDbConnection database connection.
 -	 * @param array primary keys name value pairs.
 -	 * @return TDbCommand find by primary key command.
 -	 */
 -	public function getFindByPkCommand($conn,$keys)
 -	{
 -		$columns = $this->getSelectionColumns();
 -		$primaryKeys = $this->getPrimaryKeyCriteria();
 -		$table = $this->getTableName();
 -		$sql = "SELECT {$columns} FROM {$table} WHERE {$primaryKeys}";
 -		$command = $this->createBindedCommand($conn, $sql, $this->getPrimaryKeys(), $keys);
 -		return $command;
 -	}
 -
 -	/**
 -	 * SQL database command for finding records by a list of primary keys.
 -	 * @param TDbConnection database connection.
 -	 * @param array list of primary keys to match.
 -	 * @return TDbCommand find by list of primary keys command.
 -	 */
 -	public function getFindInPksCommand($conn, $keys)
 -	{
 -		$conn->setActive(true);
 -		$columns = $this->getSelectionColumns();
 -		$table = $this->getTableName();
 -		$criteria = $this->getCompositeKeysCriteria($conn,$keys);
 -		$sql = "SELECT {$columns} FROM {$table} WHERE {$criteria}";
 -		$command = $conn->createCommand($sql);
 -		$command->prepare();
 -		return $command;
 -	}
 -
 -	/**
 -	 * SQL database command for finding records using a criteria object.
 -	 * @param TDbConnection database connection.
 -	 * @param TActiveRecordCriteria criteria object
 -	 * @return TDbCommand find by criteria command.
 -	 */
 -	public function getFindByCriteriaCommand($conn, $criteria=null)
 -	{
 -		$columns = $this->getSelectionColumns();
 -		$conditions = $this->getSqlFromCriteria($conn,$criteria);
 -		$table = $this->getTableName();
 -		$sql = "SELECT {$columns} FROM {$table} {$conditions}";
 -		return $this->createCriteriaBindedCommand($conn,$sql, $criteria);
 -	}
 -
 -	/**
 -	 * Command to count the number of record matching the criteria.
 -	 * @param TDbConnection database connection.
 -	 * @param TActiveRecordCriteria criteria object
 -	 * @return TDbCommand count command.
 -	 * 	 */
 -	public function getCountRecordsCommand($conn, $criteria)
 -	{
 -		$columns = $this->getSelectionColumns();
 -		$conditions = $this->getSqlFromCriteria($conn,$criteria);
 -		$table = $this->getTableName();
 -		$sql = "SELECT count(*) FROM {$table} {$conditions}";
 -		return $this->createCriteriaBindedCommand($conn,$sql, $criteria);
 -	}
 -
 -	abstract protected function getSqlFromCriteria($conn, $criteria);
 -
 -	/**
 -	 * Sql command with parameters binded.
 -	 * @param TDbConnection database connection.
 -	 * @param string sql query.
 -	 * @param array parameters to be bound
 -	 * @return TDbCommand sql command.
 -	 */
 -	public function getFindBySqlCommand($conn,$sql,$parameters)
 -	{
 -		$conn->setActive(true);
 -		$command = $conn->createCommand($sql);
 -		$this->bindParameterValues($conn,$command,$parameters);
 -		return $command;
 -	}
 -
 -	/**
 -	 * SQL database command for insert a new record.
 -	 * @param TDbConnection database connection.
 -	 * @param TActiveRecord new record to be inserted.
 -	 * @return TDbCommand active record insert command
 -	 */
 -	public function getInsertCommand($conn, $record)
 -	{
 -		$columns = $this->getInsertableColumns($record);
 -		$fields = $this->getInsertColumNames($columns);
 -		$inserts = $this->getInsertColumnValues($columns);
 -		$table = $this->getTableName();
 -		$sql = "INSERT INTO {$table} ({$fields}) VALUES ({$inserts})";
 -		return $this->createBindedCommand($conn, $sql, array_keys($columns), $columns);
 -	}
 -
 -	/**
 -	 * Update the record object's sequence values after insert.
 -	 * @param TDbConnection database connection.
 -	 * @param TActiveRecord record object.
 -	 */
 -	public function updatePostInsert($conn, $record)
 -	{
 -		foreach($this->getColumns() as $name => $column)
 -		{
 -			if($column->hasSequence())
 -				$record->{$name} = $conn->getLastInsertID($column->getSequenceName());
 -		}
 -	}
 -
 -	/**
 -	 * SQL database command to update an active record.
 -	 * @param TDbConnection database connection.
 -	 * @param TActiveRecord record for update.
 -	 * @return TDbCommand update command.
 -	 */
 -	public function getUpdateCommand($conn,$record)
 -	{
 -		$primaryKeys = $this->getPrimaryKeyCriteria();
 -		$columns = $this->getUpdatableColumns($record);
 -		$updates = $this->getUpdateBindings($columns);
 -		$table = $this->getTableName();
 -		$sql = "UPDATE {$table} SET {$updates} WHERE {$primaryKeys}";
 -		$primaryKeyValues = $this->getObjectKeyValues($this->getPrimaryKeys(), $record);
 -		$values = array_merge($columns, $primaryKeyValues);
 -		return $this->createBindedCommand($conn, $sql, array_keys($values), $values);
 -	}
 -
 -	/**
 -	 * SQL database command to delete an active record.
 -	 * @param TDbConnection database connection.
 -	 * @param TActiveRecord record for deletion.
 -	 * @return TDbCommand delete command.
 -	 */
 -	public function getDeleteCommand($conn,$record)
 -	{
 -		$primaryKeys = $this->getPrimaryKeyCriteria();
 -		$table = $this->getTableName();
 -		$sql = "DELETE FROM {$table} WHERE {$primaryKeys}";
 -		$keys = $this->getPrimaryKeys();
 -		$values = $this->getObjectKeyValues($keys, $record);
 -		return $this->createBindedCommand($conn,$sql, $keys, $values);
 -	}
 -
 -	/**
 -	 * SQL command to delete records by primary keys.
 -	 * @param TDbConnection database connection.
 -	 * @param array list of primary keys
 -	 * @return TDbCommand delete command.
 -	 */
 -	public function getDeleteByPkCommand($conn,$keys)
 -	{
 -		$conn->setActive(true);
 -		$table = $this->getTableName();
 -		$criteria = $this->getCompositeKeysCriteria($conn, $keys);
 -		$sql = "DELETE FROM {$table} WHERE {$criteria}";
 -		$command = $conn->createCommand($sql);
 -		$command->prepare();
 -		return $command;
 -	}
 -
 -
 -	/**
 -	 * SQL command to delete records by criteria
 -	 * @param TDbConnection database connection.
 -	 * @param TActiveRecordCriteria criteria object.
 -	 * @return TDbCommand delete command.
 -	 */
 -	public function getDeleteByCriteriaCommand($conn, $criteria)
 -	{
 -		$conditions = $this->getSqlFromCriteria($conn,$criteria);
 -		$table = $this->getTableName();
 -		$sql = "DELETE FROM {$table} {$conditions}";
 -		return $this->createCriteriaBindedCommand($conn,$sql, $criteria);
 -	}
 -}
 - -?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Vendor/TDbMetaDataInspector.php b/framework/Data/ActiveRecord/Vendor/TDbMetaDataInspector.php deleted file mode 100644 index 6c23ccb2..00000000 --- a/framework/Data/ActiveRecord/Vendor/TDbMetaDataInspector.php +++ /dev/null @@ -1,82 +0,0 @@ -<?php -/**
 - * TDbMetaDataInspector class file.
 - *
 - * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 - * @link http://www.pradosoft.com/
 - * @copyright Copyright © 2005-2007 PradoSoft
 - * @license http://www.pradosoft.com/license/
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - */
 -
 -/**
 - * Base class for database meta data inspectors.
 - *
 - * @author Wei Zhuo <weizho[at]gmail[dot]com>
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - * @since 3.1
 - */
 -abstract class TDbMetaDataInspector
 -{
 -	private $_connection;
 -
 -	public function __construct($conn)
 -	{
 -		$this->setDbConnection($conn);
 -	}
 -
 -	/**
 -	 * @param TDbConnection database connection.
 -	 */
 -	public function setDbConnection($conn)
 -	{
 -		$this->_connection=$conn;
 -	}
 -
 -	/**
 -	 * @return TDbConnection database connection.
 -	 */
 -	public function getDbConnection()
 -	{
 -		return $this->_connection;
 -	}
 -
 -	/**
 -	 * @param string table name
 -	 * @return TDbMetaData table meta data.
 -	 */
 -	public function getTableMetaData($table)
 -	{
 -		$keys = $this->getConstraintKeys($table);
 -		$columns = $this->getColumnDefinitions($table);
 -		return $this->createMetaData($table,$columns,$keys['primary'], $keys['foreign']);
 -	}
 -
 -	/**
 -	 * Get the column definitions for given table.
 -	 * @param string table name.
 -	 * @return array column name value pairs of column meta data.
 -	 */
 -	abstract protected function getColumnDefinitions($table);
 -
 -	/**
 -	 * Gets the primary and foreign key details for the given table.
 -	 * @param string table name.
 -	 * @return array key value pairs with keys 'primary' and 'foreign'.
 -	 */
 -	abstract protected function getConstraintKeys($table);
 -
 -	/**
 -	 * Create a new instance of meta data.
 -	 * @param string table name
 -	 * @param array column meta data
 -	 * @param array primary key meta data
 -	 * @param array foreign key meta data.
 -	 * @return TDbMetaData table meta data.
 -	 */
 -	abstract protected function createMetaData($table, $columns, $primary, $foreign);
 -}
 - -?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Vendor/TIbmColumnMetaData.php b/framework/Data/ActiveRecord/Vendor/TIbmColumnMetaData.php deleted file mode 100644 index eafadae5..00000000 --- a/framework/Data/ActiveRecord/Vendor/TIbmColumnMetaData.php +++ /dev/null @@ -1,157 +0,0 @@ -<?php
 -/**
 - * TIbmColumnMetaData class file.
 - *
 - * @author Cesar Ramos <cramos[at]gmail[dot]com>
 - * @link http://www.pradosoft.com/
 - * @copyright Copyright © 2005-2007 PradoSoft
 - * @license http://www.pradosoft.com/license/
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - */
 -
 -/**
 - * TIbmColumnMetaData class.
 - *
 - * Column details for IBM DB2 database. Using php_pdo_ibm.dll extension.
 - *
 - * @author Cesar Ramos <cramos[at]gmail[dot]com>
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - * @since 3.1
 - */
 -class TIbmColumnMetaData extends TComponent
 -{
 -	private $_name;
 -	private $_type;
 -	private $_length;
 -	private $_autoIncrement;
 -	private $_default;
 -	private $_notNull=true;
 -
 -	private $_isPrimary=null;
 -
 -	private $_property;
 -
 -	/**
 -	 * Initialize column meta data.
 -	 *
 -	 * @param string column name.
 -	 * @param string column data type.
 -	 * @param string column data length.
 -	 * @param boolean column can not be null.
 -	 * @param string serial name.
 -	 * @param string default value.
 -	 */
 -	public function __construct($name,$type,$length,$notNull,$autoIncrement,$default,$primary)
 -	{
 -		$this->_property=$name;
 -		$this->_name=$name;
 -		$this->_type=$type;
 -		$this->_length=$length;
 -		$this->_notNull=$notNull;
 -		$this->_autoIncrement=$autoIncrement;
 -		$this->_default=$default;
 -		$this->_isPrimary=$primary;
 -	}
 -
 -	/**
 -	 * @return string quoted column name.
 -	 */
 -	public function getName()
 -	{
 -		return $this->_name;
 -	}
 -
 -	/**
 -	 * @return integer length.
 -	 */
 -	public function getLength()
 -	{
 -		return $this->_length;
 -	}
 -
 -	/**
 -	 * @return string active record property name
 -	 */
 -	public function getProperty()
 -	{
 -		return $this->_property;
 -	}
 -
 -	/**
 -	 * @return boolean true if column is a sequence, false otherwise.
 -	 */
 -	public function hasSequence()
 -	{
 -		return $this->_autoIncrement;
 -	}
 -
 -	/**
 -	 * @return null no sequence name.
 -	 */
 -	public function getSequenceName()
 -	{
 -		return null;
 -	}
 -
 -	/**
 -	 * @return boolean true if the column is a primary key, or part of a composite primary key.
 -	 */
 -	public function getIsPrimaryKey()
 -	{
 -		return $this->_isPrimary;
 -	}
 -
 -	/**
 -	 * @return string column type
 -	 */
 -	public function getType()
 -	{
 -		return $this->_type;
 -	}
 -
 -
 -	/**
 -	 * @return boolean false if column can be null, true otherwise.
 -	 */
 -	public function getNotNull()
 -	{
 -		return $this->_notNull;
 -	}
 -
 -	/**
 -	 * @return boolean true if column has default value, false otherwise.
 -	 */
 -	public function hasDefault()
 -	{
 -		return $this->_default !== null;
 -	}
 -
 -	/**
 -	 * @return string default column value.
 -	 */
 -	public function getDefaultValue()
 -	{
 -		return $this->_default;
 -	}
 -
 -	/**
 -	 * @return string PHP primative type derived from the column type.
 -	 */
 -	public function getPHPType()
 -	{
 -		switch(strtolower($this->_type))
 -		{
 -			case 'smallint': case 'integer':
 -				return 'integer';
 -			case 'real': case 'float': case 'double': case 'decimal': case 'bigint':
 -				return 'float';
 -			default:
 -				return 'string';
 -		}
 -	}
 -
 -}
 -
 -?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Vendor/TIbmMetaData.php b/framework/Data/ActiveRecord/Vendor/TIbmMetaData.php deleted file mode 100644 index eeaea851..00000000 --- a/framework/Data/ActiveRecord/Vendor/TIbmMetaData.php +++ /dev/null @@ -1,113 +0,0 @@ -<?php
 -
 -/**
 - * TIbmMetaData class file.
 - *
 - * @author Cesar Ramos <cramos[at]gmail[dot]com>
 - * @link http://www.pradosoft.com/
 - * @copyright Copyright © 2005-2007 PradoSoft
 - * @license http://www.pradosoft.com/license/
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - */
 -Prado::using('System.Data.ActiveRecord.Vendor.TDbMetaDataCommon');
 -
 -/**
 - * TIbmMetaData class.
 - *
 - * Column details for IBM DB2 database. Using php_pdo_ibm.dll extension.
 - *
 - * Does not support LIMIT and OFFSET criterias.
 - *
 - * @author Cesar Ramos <cramos[at]gmail[dot]com>
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - * @since 3.1
 - */
 -class TIbmMetaData extends TDbMetaDataCommon
 -{
 -	/**
 -	 * Build the SQL search string from the criteria object for IBM DB2 database.
 -	 * @param TDbConnection database connection.
 -	 * @param TActiveRecordCriteria search criteria.
 -	 * @return string SQL search.
 -	 */
 -	protected function getSqlFromCriteria($conn, $criteria)
 -	{
 -		if($criteria===null) return '';
 -		$sql = '';
 -		if(($condition = $criteria->getCondition())!==null)
 -			$sql .= ' WHERE '.$condition;
 -		$orders=array();
 -		foreach($criteria->getOrdersBy() as $by=>$ordering)
 -			$orders[] = $this->getOrdering($by, $ordering);
 -		if(count($orders) > 0)
 -			$sql .= ' ORDER BY '.implode(', ', $orders);
 -		//if(($limit = $criteria->getLimit())!==null)
 -		//{
 -		//	$sql .= ' FETCH FIRST '.intval($limit).' ROWS ONLY';
 -		//}
 -		return strlen($sql) > 0 ? $sql : '';
 -	}
 -
 -	/**
 -	 * Lowercase the data keys, IBM DB2 returns uppercase column names
 -	 * @param mixed record row
 -	 * @return array record row
 -	 */
 -	public function postQueryRow($row)
 -	{
 -		if(!is_array($row)) return $row;
 -		$result=array();
 -		foreach($row as $k=>$v)
 -			$result[strtolower($k)]=$v;
 -		return $result;
 -	}
 -
 -	/**
 -	 * Lowercase the data keys, IBM DB2 returns uppercase column names
 -	 * @param mixed record row
 -	 * @return array record row
 -	 */
 -	public function postQuery($rows)
 -	{
 -		$data = array();
 -		foreach($rows as $k=>$v)
 -			$data[$k] = $this->postQueryRow($v);
 -		return $data;
 -	}
 -	
 -	public function getSearchRegExpCriteria($fields, $keywords)
 -	{
 -		if(strlen(trim($keywords)) == 0) return '';
 -		$words = array();
 -		preg_match_all('/([a-zA-Z0-9-+]+)/', $keywords, $words);
 -		$result = array();
 -		foreach($fields as $field)
 -		{
 -			$column = $this->getColumn($field);
 -			if($this->isSearchableColumn($column))
 -				$result[] = $this->getLikeCriteriaStr($column->getName(), $words[0]);
 -		}
 -			$a = '('.implode(' OR ', $result).')';
 -			error_log($a);
 -		return '('.implode(' OR ', $result).')';
 -	}
 -
 -	protected function isSearchableColumn($column)
 -	{
 -		$type = strtolower($column->getType());
 -		return $type === 'char' || $type === 'varchar';
 -	}
 -
 -	protected function getLikeCriteriaStr($column, $words)
 -	{
 -		$result=array();
 -		foreach($words as $word)
 -			$result[] = "{$column} LIKE '%{$word}%'";
 -		return '('.implode(' AND ', $result).')';
 -	}
 -
 -	
 -}
 -?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Vendor/TIbmMetaDataInspector.php b/framework/Data/ActiveRecord/Vendor/TIbmMetaDataInspector.php deleted file mode 100644 index 3920ac39..00000000 --- a/framework/Data/ActiveRecord/Vendor/TIbmMetaDataInspector.php +++ /dev/null @@ -1,113 +0,0 @@ -<?php
 -/**
 - * TIbmMetaDataInspector class file.
 - *
 - * @author Cesar Ramos <cramos[at]gmail[dot]com>
 - * @link http://www.pradosoft.com/
 - * @copyright Copyright © 2005-2007 PradoSoft
 - * @license http://www.pradosoft.com/license/
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - */
 -Prado::using('System.Data.ActiveRecord.Vendor.TDbMetaDataInspector');
 -Prado::using('System.Data.ActiveRecord.Vendor.TIbmColumnMetaData');
 -Prado::using('System.Data.ActiveRecord.Vendor.TIbmMetaData');
 -
 -/**
 - * TIbmMetaDataInspector class.
 - *
 - * Column details for IBM DB2 database. Using php_pdo_ibm.dll extension.
 - *
 - * @author Cesar Ramos <cramos[at]gmail[dot]com>
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - * @since 3.1
 - */
 -class TIbmMetaDataInspector extends TDbMetaDataInspector
 -{
 -	private $_schema;
 -
 -	/**
 -	 * @param string default schema.
 -	 */
 -	public function setSchema($schema)
 -	{
 -		$this->_schema=$schema;
 -	}
 -
 -	/**
 -	 * @return string default schema.
 -	 */
 -	public function getSchema()
 -	{
 -		return $this->_schema;
 -	}
 -	/**
 -	 * Get the column definitions for given table.
 -	 * @param string table name.
 -	 * @return array column name value pairs of column meta data.
 -	 */
 -	protected function getColumnDefinitions($table)
 -	{
 -		if(count($parts= explode('.', $table)) > 1)
 -		{
 -			$tablename = $parts[1];
 -			$schema = $parts[0];
 -		}
 -		else
 -		{
 -			$tablename = $parts[0];
 -			$schema = $this->getSchema();
 -		}
 -		$sql="SELECT * FROM SYSCAT.COLUMNS WHERE TABNAME='".strtoupper($tablename)."'";
 -		if ($schema)
 -			$sql=$sql." AND TABSCHEMA='".strtoupper($schema)."'";
 -
 -		$conn = $this->getDbConnection();
 -		$conn->setActive(true);
 -		$command = $conn->createCommand($sql);
 -		$command->prepare();
 -		$result=$command->query($sql);
 -		foreach ($result as $col)
 -    		$cols[strtolower($col['COLNAME'])] = $this->getColumnMetaData($col);
 -		return $cols;
 -	}
 -
 -	protected function getColumnMetaData($col)
 -	{
 -		$name = strtolower($col['COLNAME']);
 -		$type = $col['TYPENAME'];
 -		$length = $col['LENGTH'];
 -		$notNull = $col['NULLS']==='N'?1:0;
 -		$autoIncrement=$col['IDENTITY']==='Y'?1:0;
 -		$default = $col['DEFAULT'];
 -		$primaryKey = $col['KEYSEQ']?1:0;
 -		return new TIbmColumnMetaData($name,$type,$length,$notNull,$autoIncrement,$default,$primaryKey);
 -	}
 -
 -	/**
 -	 * Not implemented, IBM does not always have foreign key constraints.
 -	 */
 -	protected function getConstraintKeys($table)
 -	{
 -		return array('primary'=>array(), 'foreign'=>array());
 -	}
 -
 -	/**
 -	 * Create a new instance of meta data.
 -	 * @param string table name
 -	 * @param array column meta data
 -	 * @param array primary key meta data
 -	 * @param array foreign key meta data.
 -	 * @return TDbMetaData table meta data.
 -	 */
 -	protected function createMetaData($table, $columns, $primary, $foreign)
 -	{
 -		$pks = array();
 -		foreach($columns as $name=>$column)
 -			if($column->getIsPrimaryKey())
 -				$pks[] = $name;
 -		return new TIbmMetaData($table,$columns,$pks);
 -	}
 -}
 -?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Vendor/TMysqlColumnMetaData.php b/framework/Data/ActiveRecord/Vendor/TMysqlColumnMetaData.php deleted file mode 100644 index 7c841181..00000000 --- a/framework/Data/ActiveRecord/Vendor/TMysqlColumnMetaData.php +++ /dev/null @@ -1,172 +0,0 @@ -<?php
 -/**
 - * TMysqlColumnMetaData class file.
 - *
 - * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 - * @link http://www.pradosoft.com/
 - * @copyright Copyright © 2005-2007 PradoSoft
 - * @license http://www.pradosoft.com/license/
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - */
 -
 -/**
 - * Column meta data for Mysql database.
 - *
 - * @author Wei Zhuo <weizho[at]gmail[dot]com>
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - * @since 3.1
 - */
 -class TMysqlColumnMetaData extends TComponent
 -{
 -	private $_name;
 -	private $_type;
 -	private $_autoIncrement;
 -	private $_default;
 -	private $_notNull=true;
 -	private $_property;
 -	private $_length;
 -
 -	private $_typeValues;
 -
 -	private $_isPrimary=null;
 -
 -	/**
 -	 * Initialize column meta data.
 -	 *
 -	 * @param string column name.
 -	 * @param string column data type.
 -	 * @param string column data length.
 -	 * @param boolean column can not be null.
 -	 * @param string serial name.
 -	 * @param string default value.
 -	 */
 -	public function __construct($property, $name,$type,$notNull,$autoIncrement,$default,$primary)
 -	{
 -		$this->_property=$property;
 -		$this->_name=$name;
 -		//$this->_type=$type;
 -		$this->_notNull=$notNull;
 -		$this->_autoIncrement=$autoIncrement;
 -		$this->_default=$default;
 -		$this->_isPrimary=$primary;
 -		$this->processType($type);
 -	}
 -
 -	protected function processType($type)
 -	{
 -		if(is_int($pos=strpos($type, '(')))
 -		{
 -			$match=array();
 -			if(preg_match('/\((.*)\)/', $type, $match))
 -			{
 -				$this->_type = substr($type,0,$pos);
 -				switch(strtolower($this->_type))
 -				{
 -					case 'set':
 -					case 'enum':
 -						$this->_typeValues = preg_split('/\s*,\s*|\s+/', preg_replace('/\'|"/', '', $match[1]));
 -						break;
 -					default:
 -						$this->_length=floatval($match[1]);
 -				}
 -			}
 -			else
 -				$this->_type = $type;
 -		}
 -		else
 -			$this->_type = $type;
 -	}
 -
 -	public function getTypeValues()
 -	{
 -		return $this->_typeValues;
 -	}
 -
 -	public function getLength()
 -	{
 -		return $this->_length;
 -	}
 -
 -	/**
 -	 * @return string quoted column name.
 -	 */
 -	public function getName()
 -	{
 -		return $this->_name;
 -	}
 -
 -	/**
 -	 * @return string column name, used as active record property name
 -	 */
 -	public function getProperty()
 -	{
 -		return $this->_property;
 -	}
 -
 -	public function getPHPType()
 -	{
 -		switch(strtolower($this->_type))
 -		{
 -			case 'tinyint': case 'smallint': case 'mediumint': case 'int': case 'year':
 -				return 'integer';
 -			case 'bool':
 -				return 'boolean';
 -			case 'bigint': case 'float': case 'double': case 'decimal':
 -				return 'float';
 -			default:
 -				return 'string';
 -		}
 -	}
 -
 -	/**
 -	 * @return boolean true if column is a sequence, false otherwise.
 -	 */
 -	public function hasSequence()
 -	{
 -		return $this->_autoIncrement;
 -	}
 -
 -	/**
 -	 * @return null no sequence name.
 -	 */
 -	public function getSequenceName()
 -	{
 -		return null;
 -	}
 -
 -	/**
 -	 * @return boolean true if the column is a primary key, or part of a composite primary key.
 -	 */
 -	public function getIsPrimaryKey()
 -	{
 -		return $this->_isPrimary;
 -	}
 -
 -	public function getType()
 -	{
 -		return $this->_type;
 -	}
 -
 -
 -	public function getNotNull()
 -	{
 -		return $this->_notNull;
 -	}
 -
 -	/**
 -	 * @return boolean true if column has default value, false otherwise.
 -	 */
 -	public function hasDefault()
 -	{
 -		return $this->_default !== null;
 -	}
 -
 -	public function getDefaultValue()
 -	{
 -		return $this->_default;
 -	}
 -}
 -
 -?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php b/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php deleted file mode 100644 index 03aba53f..00000000 --- a/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php
 -/**
 - * TMysqlMetaData class file.
 - *
 - * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 - * @link http://www.pradosoft.com/
 - * @copyright Copyright © 2005-2007 PradoSoft
 - * @license http://www.pradosoft.com/license/
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - */
 -
 -Prado::using('System.Data.ActiveRecord.Vendor.TDbMetaDataCommon');
 -
 -/**
 - * TMysqlMetaData specialized command builder for Mysql database.
 - *
 - * @author Wei Zhuo <weizho[at]gmail[dot]com>
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - * @since 3.1
 - */
 -class TMysqlMetaData extends TDbMetaDataCommon
 -{
 -	/**
 -	 * Build the SQL search string from the criteria object for Postgress database.
 -	 * @param TDbConnection database connection.
 -	 * @param TActiveRecordCriteria search criteria.
 -	 * @return string SQL search.
 -	 */
 -	protected function getSqlFromCriteria($conn, $criteria)
 -	{
 -		if($criteria===null) return '';
 -		$sql = '';
 -		if(($condition = $criteria->getCondition())!==null)
 -			$sql .= ' WHERE '.$condition;
 -		$orders=array();
 -		foreach($criteria->getOrdersBy() as $by=>$ordering)
 -			$orders[] = $this->getOrdering($by, $ordering);
 -		if(count($orders) > 0)
 -			$sql .= ' ORDER BY '.implode(', ', $orders);
 -		if(($limit = $criteria->getLimit())!==null)
 -		{
 -			$offset = $criteria->getOffset();
 -			$offset = $offset===null?0:intval($offset); //assumes integer offset
 -			$sql .= ' LIMIT '.$offset.', '.intval($limit); //assumes integer limit
 -		}
 -		return strlen($sql) > 0 ? $sql : '';
 -	}
 -
 -	public function getSearchRegExpCriteria($fields, $keywords)
 -	{
 -		if(strlen(trim($keywords)) == 0) return '';
 -		$words = preg_split('/\s/', preg_quote($keywords, '\''));
 -		$result = array();
 -		foreach($fields as $field)
 -		{
 -			$column = $this->getColumn($field);
 -			$result[] = $this->getRegexpCriteriaStr($column->getName(), $words);
 -		}
 -		return '('.implode(' OR ', $result).')';
 -	}
 -
 -	protected function getRegexpCriteriaStr($column, $words)
 -	{
 -		$regexp = implode('|', $words);
 -		return "({$column} REGEXP  '{$regexp}')";
 -	}
 -
 -}
 -?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Vendor/TMysqlMetaDataInspector.php b/framework/Data/ActiveRecord/Vendor/TMysqlMetaDataInspector.php deleted file mode 100644 index 23c483d1..00000000 --- a/framework/Data/ActiveRecord/Vendor/TMysqlMetaDataInspector.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php
 -/**
 - * TMysqlMetaDataInspector class file.
 - *
 - * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 - * @link http://www.pradosoft.com/
 - * @copyright Copyright © 2005-2007 PradoSoft
 - * @license http://www.pradosoft.com/license/
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - */
 -
 -Prado::using('System.Data.ActiveRecord.Vendor.TDbMetaDataInspector');
 -Prado::using('System.Data.ActiveRecord.Vendor.TMysqlColumnMetaData');
 -Prado::using('System.Data.ActiveRecord.Vendor.TMysqlMetaData');
 -
 -/**
 - * TMysqlMetaDataInspector class.
 - *
 - * Gathers table column properties for Mysql database.
 - *
 - * @author Wei Zhuo <weizho[at]gmail[dot]com>
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - * @since 3.1
 - */
 -class TMysqlMetaDataInspector extends TDbMetaDataInspector
 -{
 -	/**
 -	 * Get the column definitions for given table.
 -	 * @param string table name.
 -	 * @return array column name value pairs of column meta data.
 -	 */
 -	protected function getColumnDefinitions($table)
 -	{
 -		$sql="SHOW FULL FIELDS FROM {$table}";
 -		$conn = $this->getDbConnection();
 -		$conn->setActive(true);
 -		$command = $conn->createCommand($sql);
 -		$command->prepare();
 -		foreach($command->query() as $col)
 -			$cols[strtolower($col['Field'])] = $this->getColumnMetaData($col);
 -		return $cols;
 -	}
 -
 -	protected function getColumnMetaData($col)
 -	{
 -		$name = '`'.$col['Field'].'`'; //quote the column names!
 -		$type = $col['Type'];
 -		$notNull = $col['Null']==='NO';
 -		$autoIncrement=is_int(strpos(strtolower($col['Extra']), 'auto_increment'));
 -		$default = $col['Default'];
 -		$primaryKey = $col['Key']==='PRI';
 -		return new TMysqlColumnMetaData(strtolower($col['Field']),$name,$type,
 -						$notNull,$autoIncrement,$default,$primaryKey);
 -	}
 -
 -	/**
 -	 * Not implemented, Mysql does not always have foreign key constraints.
 -	 */
 -	protected function getConstraintKeys($table)
 -	{
 -		return array('primary'=>array(), 'foreign'=>array());
 -	}
 -
 -	/**
 -	 * Create a new instance of meta data.
 -	 * @param string table name
 -	 * @param array column meta data
 -	 * @param array primary key meta data
 -	 * @param array foreign key meta data.
 -	 * @return TDbMetaData table meta data.
 -	 */
 -	protected function createMetaData($table, $columns, $primary, $foreign)
 -	{
 -		$pks = array();
 -		foreach($columns as $name=>$column)
 -			if($column->getIsPrimaryKey())
 -				$pks[] = $name;
 -		return new TMysqlMetaData($table,$columns,$pks);
 -	}
 -}
 - -?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Vendor/TPgsqlColumnMetaData.php b/framework/Data/ActiveRecord/Vendor/TPgsqlColumnMetaData.php deleted file mode 100644 index 2774bb54..00000000 --- a/framework/Data/ActiveRecord/Vendor/TPgsqlColumnMetaData.php +++ /dev/null @@ -1,166 +0,0 @@ -<?php
 -/**
 - * TPgsqlColumnMetaData class file.
 - *
 - * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 - * @link http://www.pradosoft.com/
 - * @copyright Copyright © 2005-2007 PradoSoft
 - * @license http://www.pradosoft.com/license/
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - */
 -
 -/**
 - * Column meta data for Postgre 7.3 or later.
 - *
 - * @author Wei Zhuo <weizho[at]gmail[dot]com>
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - * @since 3.1
 - */
 -class TPgsqlColumnMetaData extends TComponent
 -{
 -	private $_name;
 -	private $_type;
 -	private $_sequenceName;
 -	private $_default;
 -	private $_length;
 -	private $_notNull=true;
 -	private $_property;
 -
 -	private $_isPrimary=null;
 -
 -	/**
 -	 * Initialize column meta data.
 -	 *
 -	 * @param string column name.
 -	 * @param string column data type.
 -	 * @param string column data length.
 -	 * @param boolean column can not be null.
 -	 * @param string serial name.
 -	 * @param string default value.
 -	 */
 -	public function __construct($property,$name,$type,$length,$notNull,$serial,$default)
 -	{
 -		$this->_property=$property;
 -		$this->_name=$name;
 -		$this->_length=$length;
 -		$this->processType($type);
 -		$this->_notNull=$notNull;
 -		$this->_sequenceName=$serial;
 -		$this->_default=$default;
 -	}
 -
 -	protected function processType($type)
 -	{
 -		if(is_int($pos=strpos($type, '(')))
 -		{
 -			$match=array();
 -			if(preg_match('/\((.*)\)/', $type, $match))
 -			{
 -				$this->_length=floatval($match[1]);
 -				$this->_type = substr($type,0,$pos);
 -			}
 -			else
 -				$this->_type = $type;
 -		}
 -		else
 -			$this->_type = $type;
 -	}
 -
 -	/**
 -	 * @return string quoted column name.
 -	 */
 -	public function getName()
 -	{
 -		return $this->_name;
 -	}
 -
 -	/**
 -	 * @return string column name, used as active record property name
 -	 */
 -	public function getProperty()
 -	{
 -		return $this->_property;
 -	}
 -
 -	public function getPHPType()
 -	{
 -		switch(strtolower($this->_type))
 -		{
 -			case 'bit': case 'bit varying': case 'real': case 'serial': case 'int': case 'integer':
 -				return 'integer';
 -			case 'boolean':
 -				return 'boolean';
 -			case 'bigint': case 'bigserial': case 'double precision': case 'money': case 'numeric':
 -				return 'float';
 -			default:
 -				return 'string';
 -		}
 -	}
 -
 -	/**
 -	 * @return boolean true if column is a sequence, false otherwise.
 -	 */
 -	public function hasSequence()
 -	{
 -		return $this->_sequenceName != null;
 -	}
 -
 -	/**
 -	 * @return string sequence name, only applicable if column is a sequence.
 -	 */
 -	public function getSequenceName()
 -	{
 -		return $this->_sequenceName;
 -	}
 -
 -	/**
 -	 * Set the column as primary key
 -	 */
 -	public function setIsPrimaryKey($value)
 -	{
 -		if($this->_isPrimary===null)
 -			$this->_isPrimary=$value;
 -		else
 -			throw new TActiveRecordException('ar_column_meta_data_read_only');
 -	}
 -
 -	/**
 -	 * @return boolean true if the column is a primary key, or part of a composite primary key.
 -	 */
 -	public function getIsPrimaryKey()
 -	{
 -		return $this->_isPrimary===null? false : $this->_isPrimary;
 -	}
 -
 -	public function getType()
 -	{
 -		return $this->_type;
 -	}
 -
 -	public function getLength()
 -	{
 -		return $this->_length;
 -	}
 -
 -	public function getNotNull()
 -	{
 -		return $this->_notNull;
 -	}
 -
 -	/**
 -	 * @return boolean true if column has default value, false otherwise.
 -	 */
 -	public function hasDefault()
 -	{
 -		return $this->_default !== null;
 -	}
 -
 -	public function getDefaultValue()
 -	{
 -		return $this->_default;
 -	}
 -}
 -
 -?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php b/framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php deleted file mode 100644 index 45e9c7e4..00000000 --- a/framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php +++ /dev/null @@ -1,78 +0,0 @@ -<?php -/**
 - * TPgsqlMetaData class file.
 - *
 - * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 - * @link http://www.pradosoft.com/
 - * @copyright Copyright © 2005-2007 PradoSoft
 - * @license http://www.pradosoft.com/license/
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - */
 -
 -Prado::using('System.Data.ActiveRecord.Vendor.TDbMetaDataCommon');
 -
 -/**
 - * TPgsqlMetaData class.
 - *
 - * Command builder for Postgres database
 - *
 - * @author Wei Zhuo <weizho[at]gmail[dot]com>
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - * @since 3.1
 - */
 -class TPgsqlMetaData extends TDbMetaDataCommon
 -{
 -	/**
 -	 * Build the SQL search string from the criteria object for Postgress database.
 -	 * @param TDbConnection database connection.
 -	 * @param TActiveRecordCriteria search criteria.
 -	 * @return string SQL search.
 -	 */
 -	protected function getSqlFromCriteria($conn, $criteria)
 -	{
 -		if($criteria===null) return '';
 -		$sql = '';
 -		if(($condition = $criteria->getCondition())!==null)
 -			$sql .= ' WHERE '.$condition;
 -		$orders=array();
 -		foreach($criteria->getOrdersBy() as $by=>$ordering)
 -			$orders[] = $this->getOrdering($by, $ordering);
 -		if(count($orders) > 0)
 -			$sql .= ' ORDER BY '.implode(', ', $orders);
 -		if(($limit = $criteria->getLimit())!==null)
 -			$sql .= ' LIMIT '.intval($limit); //assumes integer limit?
 -		if(($offset = $criteria->getOffset())!==null)
 -			$sql .= ' OFFSET '.intval($offset); //assumes integer offset?
 -		return strlen($sql) > 0 ? $sql : '';
 -	}
 -
 -	public function getSearchRegExpCriteria($fields, $keywords)
 -	{
 -		if(strlen(trim($keywords)) == 0) return '';
 -		$words = preg_split('/\s/', preg_quote($keywords, '\''));
 -		$result = array();
 -		foreach($fields as $field)
 -		{
 -			$column = $this->getColumn($field);
 -			if($this->isSearchableColumn($column))
 -				$result[] = $this->getRegexpCriteriaStr($column->getName(), $words);
 -		}
 -		return '('.implode(' OR ', $result).')';
 -	}
 -
 -
 -	protected function isSearchableColumn($column)
 -	{
 -		$type = strtolower($column->getType());
 -		return $type === 'character varying' || $type === 'varchar' ||
 -				$type === 'character' || $type === 'char' || $type === 'text';
 -	}
 -	protected function getRegexpCriteriaStr($column, $words)
 -	{
 -		$regexp = implode('|', $words);
 -		return "({$column} ~ '{$regexp}')";
 -	}
 -} -?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Vendor/TPgsqlMetaDataInspector.php b/framework/Data/ActiveRecord/Vendor/TPgsqlMetaDataInspector.php deleted file mode 100644 index 16326353..00000000 --- a/framework/Data/ActiveRecord/Vendor/TPgsqlMetaDataInspector.php +++ /dev/null @@ -1,255 +0,0 @@ -<?php -/**
 - * TPgsqlMetaDataInspector class file.
 - *
 - * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 - * @link http://www.pradosoft.com/
 - * @copyright Copyright © 2005-2007 PradoSoft
 - * @license http://www.pradosoft.com/license/
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - */
 -
 -Prado::using('System.Data.ActiveRecord.Vendor.TDbMetaDataInspector');
 -Prado::using('System.Data.ActiveRecord.Vendor.TPgsqlColumnMetaData');
 -Prado::using('System.Data.ActiveRecord.Vendor.TPgsqlMetaData');
 -
 -/**
 - * Table meta data inspector for Postgres database 7.3 or later.
 - *
 - * @author Wei Zhuo <weizho[at]gmail[dot]com>
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - * @since 3.1
 - */
 -class TPgsqlMetaDataInspector extends TDbMetaDataInspector
 -{
 -	private $_schema = 'public';
 -
 -	/**
 -	 * @param string default schema.
 -	 */
 -	public function setDefaultSchema($schema)
 -	{
 -		$this->_schema=$schema;
 -	}
 -
 -	/**
 -	 * @return string default schema.
 -	 */
 -	public function getDefaultSchema()
 -	{
 -		return $this->_schema;
 -	}
 -
 -	/**
 -	 * Create a new instance of meta data.
 -	 * @param string table name
 -	 * @param array column meta data
 -	 * @param array primary key meta data
 -	 * @param array foreign key meta data.
 -	 * @return TDbMetaData table meta data.
 -	 */
 -	protected function createMetaData($table, $columns, $primary, $foreign)
 -	{
 -		foreach($primary as $column)
 -			$columns[$column]->setIsPrimaryKey(true);
 -		return new TPgsqlMetaData($table,$columns,$primary,$foreign,$this->getIsView($table));
 -	}
 -
 -	protected function getIsView($table)
 -	{
 -		$sql =
 -<<<EOD
 -		SELECT count(c.relname) FROM pg_catalog.pg_class c
 -		LEFT JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace)
 -		WHERE (n.nspname=:schema) AND (c.relkind = 'v'::"char") AND c.relname = :table
 -EOD;
 -		$conn=$this->getDbConnection();
 -		$conn->setActive(true);
 -		$command=$conn->createCommand($sql);
 -		$command->bindValue(':schema',$this->getDefaultSchema());
 -		$command->bindValue(':table', $table);
 -		return intval($command->queryScalar()) === 1;
 -	}
 -
 -	/**
 -	 * Get the column definitions for given table.
 -	 * @param string table name.
 -	 * @return array column name value pairs of column meta data.
 -	 */
 -	protected function getColumnDefinitions($table)
 -	{
 -		if(count($parts= explode('.', $table)) > 1)
 -		{
 -			$tablename = $parts[1];
 -			$schema = $parts[0];
 -		}
 -		else
 -		{
 -			$tablename = $parts[0];
 -			$schema = $this->getDefaultSchema();
 -		}
 -		// This query is made much more complex by the addition of the 'attisserial' field.
 -		// The subquery to get that field checks to see if there is an internally dependent
 -		// sequence on the field.
 -		$sql =
 -<<<EOD
 -		SELECT
 -			a.attname,
 -			pg_catalog.format_type(a.atttypid, a.atttypmod) as type,
 -			a.atttypmod,
 -			a.attnotnull, a.atthasdef, adef.adsrc,
 -			(
 -				SELECT 1 FROM pg_catalog.pg_depend pd, pg_catalog.pg_class pc
 -				WHERE pd.objid=pc.oid
 -				AND pd.classid=pc.tableoid
 -				AND pd.refclassid=pc.tableoid
 -				AND pd.refobjid=a.attrelid
 -				AND pd.refobjsubid=a.attnum
 -				AND pd.deptype='i'
 -				AND pc.relkind='S'
 -			) IS NOT NULL AS attisserial
 -
 -		FROM
 -			pg_catalog.pg_attribute a LEFT JOIN pg_catalog.pg_attrdef adef
 -			ON a.attrelid=adef.adrelid
 -			AND a.attnum=adef.adnum
 -			LEFT JOIN pg_catalog.pg_type t ON a.atttypid=t.oid
 -		WHERE
 -			a.attrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname=:table
 -				AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE
 -				nspname = :schema))
 -			AND a.attnum > 0 AND NOT a.attisdropped
 -		ORDER BY a.attnum
 -EOD;
 -		$conn = $this->getDbConnection();
 -		$conn->setActive(true);
 -		$command = $conn->createCommand($sql);
 -		$command->bindValue(':table', $tablename);
 -		$command->bindValue(':schema', $schema);
 -		$cols = array();
 -		foreach($command->query() as $col)
 -			$cols[strtolower($col['attname'])] = $this->getColumnMetaData($schema,$col);
 -		return $cols;
 -	}
 -
 -	/**
 -	 * Returns the column details.
 -	 * @param string schema name.
 -	 * @param array column details.
 -	 * @return TPgsqlColumnMetaData column meta data.
 -	 */
 -	protected function getColumnMetaData($schema, $col)
 -	{
 -		$name = '"'.$col['attname'].'"'; //quote the column names!
 -		$type = $col['type'];
 -
 -		// A specific constant in the 7.0 source, the length is offset by 4.
 -		$length = $col['atttypmod'] > 0 ? $col['atttypmod'] - 4 : null;
 -		$notNull = $col['attnotnull'];
 -		$nextval_serial = substr($col['adsrc'],0,8) === 'nextval(';
 -		$serial = $col['attisserial'] || $nextval_serial ? $this->getSerialName($schema,$col['adsrc']) : null;
 -		$default = $serial === null && $col['atthasdef'] ? $col['adsrc'] : null;
 -		return new TPgsqlColumnMetaData(strtolower($col['attname']),$name,
 -						$type,$length,$notNull,$serial,$default);
 -	}
 -
 -	/**
 -	 * @return string serial name if found, null otherwise.
 -	 */
 -	protected function getSerialName($schema,$src)
 -	{
 -		$matches = array();
 -		if(preg_match('/nextval\([^\']*\'([^\']+)\'[^\)]*\)/i',$src,$matches))
 -		{
 -			if(is_int(strpos($matches[1], '.')))
 -				return $matches[1];
 -			else
 -				return $schema.'.'.$matches[1];
 -		}
 -	}
 -
 -	/**
 -	 * Gets the primary and foreign key details for the given table.
 -	 * @param string table name.
 -	 * @return array key value pairs with keys 'primary' and 'foreign'.
 -	 */
 -	protected function getConstraintKeys($table)
 -	{
 -		if(count($parts= explode('.', $table)) > 1)
 -		{
 -			$tablename = $parts[1];
 -			$schema = $parts[0];
 -		}
 -		else
 -		{
 -			$tablename = $parts[0];
 -			$schema = $this->getDefaultSchema();
 -		}
 -
 -		$sql = 'SELECT
 -				pg_catalog.pg_get_constraintdef(pc.oid, true) AS consrc,
 -				pc.contype
 -			FROM
 -				pg_catalog.pg_constraint pc
 -			WHERE
 -				pc.conrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname=:table
 -					AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace
 -					WHERE nspname=:schema))
 -		';
 -		$this->getDbConnection()->setActive(true);
 -		$command = $this->getDbConnection()->createCommand($sql);
 -		$command->bindValue(':table', $tablename);
 -		$command->bindValue(':schema', $schema);
 -		$keys['primary'] = array();
 -		$keys['foreign'] = array();
 -		foreach($command->query() as $row)
 -		{
 -			if($row['contype']==='p')
 -				$keys['primary'] = $this->getPrimaryKeys($row['consrc']);
 -			else if($row['contype'] === 'f')
 -			{
 -				$fkey = $this->getForeignKeys($row['consrc']);
 -				if($fkey!==null)
 -					$keys['foreign'][] = $fkey;
 -			}
 -		}
 -		return $keys;
 -	}
 -
 -	/**
 -	 * Gets the primary key field names
 -	 * @param string pgsql primary key definition
 -	 * @return array primary key field names.
 -	 */
 -	protected function getPrimaryKeys($src)
 -	{
 -		$matches = array();
 -		if(preg_match('/PRIMARY\s+KEY\s+\(([^\)]+)\)/i', $src, $matches))
 -			return preg_split('/,\s+/',$matches[1]);
 -		return array();
 -	}
 -
 -	/**
 -	 * Gets foreign relationship constraint keys and table name
 -	 * @param string pgsql foreign key definition
 -	 * @return array foreign relationship table name and keys, null otherwise
 -	 */
 -	protected function getForeignKeys($src)
 -	{
 -		$matches = array();
 -		$brackets = '\(([^\)]+)\)';
 -		$find = "/FOREIGN\s+KEY\s+{$brackets}\s+REFERENCES\s+([^\(]+){$brackets}/i";
 -		if(preg_match($find, $src, $matches))
 -		{
 -			$keys = preg_split('/,\s+/', $matches[1]);
 -			$fkeys = array();
 -			foreach(preg_split('/,\s+/', $matches[3]) as $i => $fkey)
 -				$fkeys[$keys[$i]] = $fkey;
 -			return array('table' => $matches[2], 'keys' => $fkeys);
 -		}
 -	}
 -}
 - -?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Vendor/TSqliteColumnMetaData.php b/framework/Data/ActiveRecord/Vendor/TSqliteColumnMetaData.php deleted file mode 100644 index 8f4ded39..00000000 --- a/framework/Data/ActiveRecord/Vendor/TSqliteColumnMetaData.php +++ /dev/null @@ -1,147 +0,0 @@ -<?php -/**
 - * TSqliteColumnMetaData class file.
 - *
 - * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 - * @link http://www.pradosoft.com/
 - * @copyright Copyright © 2005-2007 PradoSoft
 - * @license http://www.pradosoft.com/license/
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - */
 -
 -/**
 - * TSqliteColumnMetaData class.
 - *
 - * Column details for SQLite version 2.x or 3.x. database.
 - *
 - * @author Wei Zhuo <weizho[at]gmail[dot]com>
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - * @since 3.1
 - */
 -class TSqliteColumnMetaData extends TComponent
 -{
 -	private $_name;
 -	private $_type;
 -	private $_notNull;
 -	private $_autoIncrement;
 -	private $_default;
 -	private $_primary=false;
 -	private $_property;
 -	private $_length;
 -
 -	public function __construct($property,$name,$type,$notNull,$autoIncrement,$default,$primary)
 -	{
 -		$this->_property=$property;
 -		$this->_name=$name;
 -		$this->_notNull=$notNull;
 -		$this->_autoIncrement=$autoIncrement;
 -		$this->_default=$default;
 -		$this->_primary=$primary;
 -		$this->processType($type);
 -	}
 -
 -	protected function processType($type)
 -	{
 -		if(is_int($pos=strpos($type, '(')))
 -		{
 -			$match=array();
 -			if(preg_match('/\((.*)\)/', $type, $match))
 -			{
 -				$this->_length=floatval($match[1]);
 -				$this->_type = substr($type,0,$pos);
 -			}
 -			else
 -				$this->_type = $type;
 -		}
 -		else
 -			$this->_type = $type;
 -	}
 -
 -	public function getLength()
 -	{
 -		return $this->_length;
 -	}
 -
 -	public function getPHPType()
 -	{
 -		switch(strtolower($this->_type))
 -		{
 -			case 'int': case 'integer': case 'mediumint': case 'smallint': case 'tinyint': case 'year':
 -				return 'integer';
 -			case 'boolean':
 -				return 'boolean';
 -			case 'decimal': case 'double': case 'float': case 'bigint':
 -				return 'float';
 -			default:
 -				return 'string';
 -		}
 -	}
 -
 -	/**
 -	 * @return string column name, used as active record property name
 -	 */
 -	public function getProperty()
 -	{
 -		return $this->_property;
 -	}
 -
 -	/**
 -	 * @return string quoted column name.
 -	 */
 -	public function getName()
 -	{
 -		return $this->_name;
 -	}
 -
 -	/**
 -	 * @return boolean true if column is a sequence, false otherwise.
 -	 */
 -	public function hasSequence()
 -	{
 -		return $this->_autoIncrement;
 -	}
 -
 -	/**
 -	 * @return null no sequence name.
 -	 */
 -	public function getSequenceName()
 -	{
 -		return null;
 -	}
 -
 -	/**
 -	 * @return boolean true if the column is a primary key, or part of a composite primary key.
 -	 */
 -	public function getIsPrimaryKey()
 -	{
 -		return $this->_primary;
 -	}
 -
 -	public function getType()
 -	{
 -		return $this->_type;
 -	}
 -
 -
 -	public function getNotNull()
 -	{
 -		return $this->_notNull;
 -	}
 -
 -	/**
 -	 * @return boolean true if column has default value, false otherwise.
 -	 */
 -	public function hasDefault()
 -	{
 -		return $this->_default !== null;
 -	}
 -
 -	public function getDefaultValue()
 -	{
 -		return $this->_default;
 -	}
 -}
 - -?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Vendor/TSqliteMetaData.php b/framework/Data/ActiveRecord/Vendor/TSqliteMetaData.php deleted file mode 100644 index c44d73cb..00000000 --- a/framework/Data/ActiveRecord/Vendor/TSqliteMetaData.php +++ /dev/null @@ -1,98 +0,0 @@ -<?php -/**
 - * TSqliteMetaData class file.
 - *
 - * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 - * @link http://www.pradosoft.com/
 - * @copyright Copyright © 2005-2007 PradoSoft
 - * @license http://www.pradosoft.com/license/
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - */
 -
 -Prado::using('System.Data.ActiveRecord.Vendor.TDbMetaDataCommon');
 -
 -/**
 - * TSqliteMetaData specialized command builder for SQLite database.
 - *
 - * @author Wei Zhuo <weizho[at]gmail[dot]com>
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - * @since 3.1
 - */
 -class TSqliteMetaData extends TDbMetaDataCommon
 -{
 -	/**
 -	 * Build the SQL search string from the criteria object for Postgress database.
 -	 * @param TDbConnection database connection.
 -	 * @param TActiveRecordCriteria search criteria.
 -	 * @return string SQL search.
 -	 */
 -	protected function getSqlFromCriteria($conn, $criteria)
 -	{
 -		if($criteria===null) return '';
 -		$sql = '';
 -		if(($condition = $criteria->getCondition())!==null)
 -			$sql .= ' WHERE '.$condition;
 -		$orders=array();
 -		foreach($criteria->getOrdersBy() as $by=>$ordering)
 -			$orders[] = $this->getOrdering($by, $ordering);
 -		if(count($orders) > 0)
 -			$sql .= ' ORDER BY '.implode(', ', $orders);
 -		if(($limit = $criteria->getLimit())!==null)
 -		{
 -			$offset = $criteria->getOffset();
 -			$offset = $offset===null?0:intval($offset); //assume integer offset?
 -			$sql .= ' LIMIT '.$offset.', '.intval($limit); //assume integer limit?
 -		}
 -		return strlen($sql) > 0 ? $sql : '';
 -	}
 -
 -	public function getSearchRegExpCriteria($fields, $keywords)
 -	{
 -		if(strlen(trim($keywords)) == 0) return '';
 -		$words = array();
 -		preg_match_all('/([a-zA-Z0-9-+]+)/', $keywords, $words);
 -		$result = array();
 -		foreach($fields as $field)
 -			$result[] = $this->getLikeCriteriaStr($this->getColumn($field)->getName(), $words[0]);
 -		return '('.implode(' OR ', $result).')';
 -	}
 -
 -	protected function getLikeCriteriaStr($column, $words)
 -	{
 -		$result=array();
 -		foreach($words as $word)
 -			$result[] = "({$column} LIKE \"%{$word}%\")";
 -		return '('.implode(' AND ', $result).')';
 -	}
 -
 -	/**
 -	 * Remove quote from the keys in the data.
 -	 * @param mixed record row
 -	 * @return array record row
 -	 */
 -	public function postQueryRow($row)
 -	{
 -		if(!is_array($row)) return $row;
 -		$result=array();
 -		foreach($row as $k=>$v)
 -			$result[str_replace('"','',$k)]=$v;
 -		return $result;
 -	}
 -
 -	/**
 -	 * Remove quote from the keys in the data.
 -	 * @param mixed record row
 -	 * @return array record row
 -	 */
 -	public function postQuery($rows)
 -	{
 -		$data = array();
 -		foreach($rows as $k=>$v)
 -			$data[$k] = $this->postQueryRow($v);
 -		return $data;
 -	}
 -}
 - -?>
\ No newline at end of file diff --git a/framework/Data/ActiveRecord/Vendor/TSqliteMetaDataInspector.php b/framework/Data/ActiveRecord/Vendor/TSqliteMetaDataInspector.php deleted file mode 100644 index 94f0bb72..00000000 --- a/framework/Data/ActiveRecord/Vendor/TSqliteMetaDataInspector.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php -/**
 - * TSqliteMetaDataInspector class file.
 - *
 - * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 - * @link http://www.pradosoft.com/
 - * @copyright Copyright © 2005-2007 PradoSoft
 - * @license http://www.pradosoft.com/license/
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - */
 -
 -Prado::using('System.Data.ActiveRecord.Vendor.TDbMetaDataInspector');
 -Prado::using('System.Data.ActiveRecord.Vendor.TSqliteColumnMetaData');
 -Prado::using('System.Data.ActiveRecord.Vendor.TSqliteMetaData');
 -
 -/**
 - * Table meta data inspector for Sqlite database.
 - *
 - * @author Wei Zhuo <weizho[at]gmail[dot]com>
 - * @version $Id$
 - * @package System.Data.ActiveRecord.Vendor
 - * @since 3.1
 - */
 -class TSqliteMetaDataInspector extends TDbMetaDataInspector
 -{
 -	/**
 -	 * Create a new instance of meta data.
 -	 * @param string table name
 -	 * @param array column meta data
 -	 * @param array primary key meta data
 -	 * @param array foreign key meta data.
 -	 * @return TDbMetaData table meta data.
 -	 */
 -	protected function createMetaData($table, $columns, $primary, $foreign)
 -	{
 -		$pks = array();
 -		foreach($columns as $name=>$column)
 -			if($column->getIsPrimaryKey())
 -				$pks[] = $name;
 -		return new TSqliteMetaData($table,$columns,$pks);
 -	}
 -
 -	/**
 -	 * Get the column definitions for given table.
 -	 * @param string table name.
 -	 * @return array column name value pairs of column meta data.
 -	 */
 -	protected function getColumnDefinitions($table)
 -	{
 -		$conn=$this->getDbConnection();
 -		$conn->setActive(true);
 -		$table = $conn->quoteString($table);
 -		$command = $conn->createCommand("PRAGMA table_info({$table})");
 -		$command->prepare();
 -		$cols = array();
 -		foreach($command->query() as $col)
 -			$cols[$col['name']] = $this->getColumnMetaData($col);
 -		return $cols;
 -	}
 -
 -	/**
 -	 * Returns the column details.
 -	 * @param array column details.
 -	 * @return TPgsqlColumnMetaData column meta data.
 -	 */
 -	protected function getColumnMetaData($col)
 -	{
 -		$name = '"'.$col['name'].'"'; //quote the column names!
 -		$type = $col['type'];
 -
 -		$notNull = $col['notnull']==='99';
 -		$primary = $col['pk']==='1';
 -		$autoIncrement = strtolower($type)==='integer' && $primary;
 -		$default = $col['dflt_value'];
 -		return new TSqliteColumnMetaData($col['name'],$name,$type,
 -						$notNull,$autoIncrement,$default,$primary);
 -	}
 -
 -	/**
 -	 * Not implemented, sqlite does not have foreign key constraints.
 -	 */
 -	protected function getConstraintKeys($table)
 -	{
 -		return array('primary'=>array(), 'foreign'=>array());
 -	}
 -}
 - -?>
\ No newline at end of file | 
