summaryrefslogtreecommitdiff
path: root/framework/Data
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Data')
-rw-r--r--framework/Data/ActiveRecord/Exceptions/TActiveRecordException.php1
-rw-r--r--framework/Data/ActiveRecord/Exceptions/messages.txt3
-rw-r--r--framework/Data/ActiveRecord/Relations/TActiveRecordBelongsTo.php1
-rw-r--r--framework/Data/ActiveRecord/Relations/TActiveRecordHasMany.php1
-rw-r--r--framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php1
-rw-r--r--framework/Data/ActiveRecord/Relations/TActiveRecordHasOne.php1
-rw-r--r--framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php1
-rw-r--r--framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php1
-rw-r--r--framework/Data/ActiveRecord/Scaffold/InputBuilder/TIbmScaffoldInput.php1
-rw-r--r--framework/Data/ActiveRecord/Scaffold/InputBuilder/TMssqlScaffoldInput.php1
-rw-r--r--framework/Data/ActiveRecord/Scaffold/InputBuilder/TMysqlScaffoldInput.php1
-rw-r--r--framework/Data/ActiveRecord/Scaffold/InputBuilder/TPgsqlScaffoldInput.php1
-rw-r--r--framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputBase.php1
-rw-r--r--framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputCommon.php1
-rw-r--r--framework/Data/ActiveRecord/Scaffold/InputBuilder/TSqliteScaffoldInput.php1
-rw-r--r--framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php1
-rw-r--r--framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php1
-rw-r--r--framework/Data/ActiveRecord/Scaffold/TScaffoldListView.php1
-rw-r--r--framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php1
-rw-r--r--framework/Data/ActiveRecord/Scaffold/TScaffoldView.php1
-rw-r--r--framework/Data/ActiveRecord/TActiveRecord.php29
-rw-r--r--framework/Data/ActiveRecord/TActiveRecordConfig.php1
-rw-r--r--framework/Data/ActiveRecord/TActiveRecordCriteria.php1
-rw-r--r--framework/Data/ActiveRecord/TActiveRecordGateway.php839
-rw-r--r--framework/Data/ActiveRecord/TActiveRecordManager.php1
-rw-r--r--framework/Data/Common/IbmDb2/TIbmColumnMetaData.php1
-rw-r--r--framework/Data/Common/IbmDb2/TIbmMetaData.php1
-rw-r--r--framework/Data/Common/IbmDb2/TIbmMetaDataInspector.php1
-rw-r--r--framework/Data/Common/Mssql/TMssqlCommandBuilder.php1
-rw-r--r--framework/Data/Common/Mssql/TMssqlMetaData.php1
-rw-r--r--framework/Data/Common/Mssql/TMssqlTableColumn.php1
-rw-r--r--framework/Data/Common/Mssql/TMssqlTableInfo.php1
-rw-r--r--framework/Data/Common/Mysql/TMysqlCommandBuilder.php1
-rw-r--r--framework/Data/Common/Mysql/TMysqlMetaData.php5
-rw-r--r--framework/Data/Common/Mysql/TMysqlTableColumn.php1
-rw-r--r--framework/Data/Common/Pgsql/TPgsqlCommandBuilder.php1
-rw-r--r--framework/Data/Common/Pgsql/TPgsqlMetaData.php1
-rw-r--r--framework/Data/Common/Pgsql/TPgsqlTableColumn.php1
-rw-r--r--framework/Data/Common/Pgsql/TPgsqlTableInfo.php1
-rw-r--r--framework/Data/Common/Sqlite/TSqliteCommandBuilder.php1
-rw-r--r--framework/Data/Common/Sqlite/TSqliteMetaData.php1
-rw-r--r--framework/Data/Common/Sqlite/TSqliteTableColumn.php1
-rw-r--r--framework/Data/Common/Sqlite/TSqliteTableInfo.php1
-rw-r--r--framework/Data/Common/TDbMetaData.php1
-rw-r--r--framework/Data/Common/TDbTableColumn.php1
-rw-r--r--framework/Data/Common/TDbTableInfo.php1
-rw-r--r--framework/Data/DataGateway/TTableGateway.php1
-rw-r--r--framework/Data/SqlMap/Configuration/TDiscriminator.php1
-rw-r--r--framework/Data/SqlMap/Configuration/TInlineParameterMapParser.php3
-rw-r--r--framework/Data/SqlMap/Configuration/TParameterMap.php1
-rw-r--r--framework/Data/SqlMap/Configuration/TParameterProperty.php1
-rw-r--r--framework/Data/SqlMap/Configuration/TResultMap.php1
-rw-r--r--framework/Data/SqlMap/Configuration/TResultProperty.php1
-rw-r--r--framework/Data/SqlMap/Configuration/TSimpleDynamicParser.php1
-rw-r--r--framework/Data/SqlMap/Configuration/TSqlMapCacheModel.php1
-rw-r--r--framework/Data/SqlMap/Configuration/TSqlMapStatement.php1
-rw-r--r--framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php15
-rw-r--r--framework/Data/SqlMap/DataMapper/TLazyLoadList.php1
-rw-r--r--framework/Data/SqlMap/DataMapper/TPropertyAccess.php3
-rw-r--r--framework/Data/SqlMap/DataMapper/TSqlMapCache.php1
-rw-r--r--framework/Data/SqlMap/DataMapper/TSqlMapException.php1
-rw-r--r--framework/Data/SqlMap/DataMapper/TSqlMapPagedList.php1
-rw-r--r--framework/Data/SqlMap/DataMapper/TSqlMapTypeHandlerRegistry.php1
-rw-r--r--framework/Data/SqlMap/Statements/IMappedStatement.php1
-rw-r--r--framework/Data/SqlMap/Statements/TCachingStatement.php1
-rw-r--r--framework/Data/SqlMap/Statements/TDeleteMappedStatement.php1
-rw-r--r--framework/Data/SqlMap/Statements/TInsertMappedStatement.php1
-rw-r--r--framework/Data/SqlMap/Statements/TMappedStatement.php7
-rw-r--r--framework/Data/SqlMap/Statements/TPreparedCommand.php1
-rw-r--r--framework/Data/SqlMap/Statements/TPreparedStatement.php1
-rw-r--r--framework/Data/SqlMap/Statements/TPreparedStatementFactory.php1
-rw-r--r--framework/Data/SqlMap/Statements/TSelectMappedStatement.php1
-rw-r--r--framework/Data/SqlMap/Statements/TSimpleDynamicSql.php1
-rw-r--r--framework/Data/SqlMap/Statements/TStaticSql.php1
-rw-r--r--framework/Data/SqlMap/Statements/TUpdateMappedStatement.php1
-rw-r--r--framework/Data/SqlMap/TSqlMapConfig.php1
-rw-r--r--framework/Data/SqlMap/TSqlMapGateway.php1
-rw-r--r--framework/Data/SqlMap/TSqlMapManager.php1
-rw-r--r--framework/Data/TDataSourceConfig.php2
-rw-r--r--framework/Data/TDbCommand.php1
-rw-r--r--framework/Data/TDbConnection.php6
-rw-r--r--framework/Data/TDbDataReader.php1
-rw-r--r--framework/Data/TDbTransaction.php1
83 files changed, 479 insertions, 506 deletions
diff --git a/framework/Data/ActiveRecord/Exceptions/TActiveRecordException.php b/framework/Data/ActiveRecord/Exceptions/TActiveRecordException.php
index be88f015..eaab5735 100644
--- a/framework/Data/ActiveRecord/Exceptions/TActiveRecordException.php
+++ b/framework/Data/ActiveRecord/Exceptions/TActiveRecordException.php
@@ -39,4 +39,3 @@ class TActiveRecordConfigurationException extends TActiveRecordException
}
-?>
diff --git a/framework/Data/ActiveRecord/Exceptions/messages.txt b/framework/Data/ActiveRecord/Exceptions/messages.txt
index fabfc1a4..0702c840 100644
--- a/framework/Data/ActiveRecord/Exceptions/messages.txt
+++ b/framework/Data/ActiveRecord/Exceptions/messages.txt
@@ -10,6 +10,7 @@ ar_primary_key_is_scalar = Primary key '{1}' in table '{0}' is NOT a composi
ar_invalid_db_connection = Missing or invalid default database connection for ActiveRecord class '{0}', default connection is set by the DbConnection property of TActiveRecordManager.
ar_mismatch_args_exception = ActiveRecord finder method '{0}' expects {1} parameters but found only {2} parameters instead.
ar_invalid_tablename_property = Constant {0}::{1} must be a valid database table name.
+ar_invalid_tablename_method = Method {0}::{1} must return a valid database table name.
ar_value_must_not_be_null = Property '{0}::${2}' must not be null as defined by column '{2}' in table '{1}'.
ar_missing_pk_values = Missing primary key values in forming IN(key1, key2, ...) for table '{0}'.
ar_pk_value_count_mismatch = Composite key value count mismatch in forming IN( (key1, key2, ..), (key3, key4, ..)) for table '{0}'.
@@ -21,4 +22,4 @@ ar_invalid_criteria = Invalid criteria object, must be a string or instanc
ar_relations_undefined = Unable to determine Active Record relationships because static array property {0}::${1} is not defined.
ar_undefined_relation_prop = Unable to find {1}::${2}['{0}'], Active Record relationship definition for property "{0}" not found in entries of {1}::${2}.
ar_invalid_relationship = Invalid active record relationship.
-ar_relations_missing_fk = Unable to find foreign key relationships in table '{0}' that corresponds to table '{1}'. \ No newline at end of file
+ar_relations_missing_fk = Unable to find foreign key relationships in table '{0}' that corresponds to table '{1}'.
diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordBelongsTo.php b/framework/Data/ActiveRecord/Relations/TActiveRecordBelongsTo.php
index 9f8777e2..40936011 100644
--- a/framework/Data/ActiveRecord/Relations/TActiveRecordBelongsTo.php
+++ b/framework/Data/ActiveRecord/Relations/TActiveRecordBelongsTo.php
@@ -136,4 +136,3 @@ class TActiveRecordBelongsTo extends TActiveRecordRelation
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordHasMany.php b/framework/Data/ActiveRecord/Relations/TActiveRecordHasMany.php
index c66afa14..6f191b9f 100644
--- a/framework/Data/ActiveRecord/Relations/TActiveRecordHasMany.php
+++ b/framework/Data/ActiveRecord/Relations/TActiveRecordHasMany.php
@@ -119,4 +119,3 @@ class TActiveRecordHasMany extends TActiveRecordRelation
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php b/framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php
index 9b01d323..4c71f91c 100644
--- a/framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php
+++ b/framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php
@@ -374,4 +374,3 @@ class TActiveRecordHasManyAssociation extends TActiveRecordRelation
return $data;
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordHasOne.php b/framework/Data/ActiveRecord/Relations/TActiveRecordHasOne.php
index 6e8d30de..b1aa7b91 100644
--- a/framework/Data/ActiveRecord/Relations/TActiveRecordHasOne.php
+++ b/framework/Data/ActiveRecord/Relations/TActiveRecordHasOne.php
@@ -143,4 +143,3 @@ class TActiveRecordHasOne extends TActiveRecordRelation
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php b/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php
index 4044a5ce..a352cb07 100644
--- a/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php
+++ b/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php
@@ -247,4 +247,3 @@ abstract class TActiveRecordRelation
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php b/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php
index 329007af..696bb5b1 100644
--- a/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php
+++ b/framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php
@@ -228,4 +228,3 @@ class TActiveRecordRelationContext
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TIbmScaffoldInput.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TIbmScaffoldInput.php
index 05de2019..c8177d5e 100644
--- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TIbmScaffoldInput.php
+++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TIbmScaffoldInput.php
@@ -49,4 +49,3 @@ class TIbmScaffoldInput extends TScaffoldInputCommon
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMssqlScaffoldInput.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMssqlScaffoldInput.php
index bca1bcb2..be495e98 100644
--- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMssqlScaffoldInput.php
+++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMssqlScaffoldInput.php
@@ -51,4 +51,3 @@ class TMssqlScaffoldInput extends TScaffoldInputCommon
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMysqlScaffoldInput.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMysqlScaffoldInput.php
index a8ecdd13..c06e4113 100644
--- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMysqlScaffoldInput.php
+++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TMysqlScaffoldInput.php
@@ -81,4 +81,3 @@ class TMysqlScaffoldInput extends TScaffoldInputCommon
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TPgsqlScaffoldInput.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TPgsqlScaffoldInput.php
index 69b67e7f..cd244b27 100644
--- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TPgsqlScaffoldInput.php
+++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TPgsqlScaffoldInput.php
@@ -52,4 +52,3 @@ class TPgsqlScaffoldInput extends TScaffoldInputCommon
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputBase.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputBase.php
index ad563f2f..d8db9c59 100644
--- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputBase.php
+++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputBase.php
@@ -101,4 +101,3 @@ class TScaffoldInputBase
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputCommon.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputCommon.php
index 12f9bc25..d02bc9a0 100644
--- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputCommon.php
+++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputCommon.php
@@ -307,4 +307,3 @@ class TScaffoldInputCommon extends TScaffoldInputBase
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TSqliteScaffoldInput.php b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TSqliteScaffoldInput.php
index c187e825..5f431067 100644
--- a/framework/Data/ActiveRecord/Scaffold/InputBuilder/TSqliteScaffoldInput.php
+++ b/framework/Data/ActiveRecord/Scaffold/InputBuilder/TSqliteScaffoldInput.php
@@ -97,4 +97,3 @@ class TSqliteScaffoldInput extends TScaffoldInputCommon
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php b/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php
index 1e9b87e7..9c548308 100644
--- a/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php
+++ b/framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php
@@ -204,4 +204,3 @@ abstract class TScaffoldBase extends TTemplateControl
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php b/framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php
index 1760b27d..b38b739f 100644
--- a/framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php
+++ b/framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php
@@ -307,4 +307,3 @@ interface IScaffoldEditRenderer extends IDataRenderer
public function updateRecord($record);
}
-?>
diff --git a/framework/Data/ActiveRecord/Scaffold/TScaffoldListView.php b/framework/Data/ActiveRecord/Scaffold/TScaffoldListView.php
index 79ab40ab..6c28651a 100644
--- a/framework/Data/ActiveRecord/Scaffold/TScaffoldListView.php
+++ b/framework/Data/ActiveRecord/Scaffold/TScaffoldListView.php
@@ -304,4 +304,3 @@ class TScaffoldListView extends TScaffoldBase
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php b/framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php
index a7f58735..b1cd6cbc 100644
--- a/framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php
+++ b/framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php
@@ -148,4 +148,3 @@ class TScaffoldSearch extends TScaffoldBase
}
}
-?>
diff --git a/framework/Data/ActiveRecord/Scaffold/TScaffoldView.php b/framework/Data/ActiveRecord/Scaffold/TScaffoldView.php
index 1ddba335..04420e9a 100644
--- a/framework/Data/ActiveRecord/Scaffold/TScaffoldView.php
+++ b/framework/Data/ActiveRecord/Scaffold/TScaffoldView.php
@@ -141,4 +141,3 @@ class TScaffoldView extends TScaffoldBase
}
}
-?>
diff --git a/framework/Data/ActiveRecord/TActiveRecord.php b/framework/Data/ActiveRecord/TActiveRecord.php
index 370dd69a..fa134a9f 100644
--- a/framework/Data/ActiveRecord/TActiveRecord.php
+++ b/framework/Data/ActiveRecord/TActiveRecord.php
@@ -79,7 +79,7 @@ Prado::using('System.Data.ActiveRecord.Relations.TActiveRecordRelationContext');
* 'email_address'=>'email',
* );
* public $username;
- * pulbic $email;
+ * public $email;
* }
* </code>
* In the above, the 'users' table consists of 'user_id' and 'email_address' columns,
@@ -129,6 +129,18 @@ Prado::using('System.Data.ActiveRecord.Relations.TActiveRecordRelationContext');
* }
* </code>
*
+ * Since v3.1.3 you can also define a method that returns the table name.
+ * <code>
+ * class UserRecord extends TActiveRecord
+ * {
+ * public function table()
+ * {
+ * return 'users';
+ * }
+ *
+ * }
+ * </code>
+ *
* @author Wei Zhuo <weizho[at]gmail[dot]com>
* @version $Id$
* @package System.Data.ActiveRecord
@@ -318,6 +330,14 @@ abstract class TActiveRecord extends TComponent
}
/**
+ * @return TDbTableInfo the meta information of the table associated with this AR class.
+ */
+ public function getRecordTableInfo()
+ {
+ return $this->getRecordGateway()->getRecordTableInfo($this);
+ }
+
+ /**
* Compare two records using their primary key values (all column values if
* table does not defined primary keys). The default uses simple == for
* comparison of their values. Set $strict=true for identity comparison (===).
@@ -329,7 +349,7 @@ abstract class TActiveRecord extends TComponent
{
if($record===null || get_class($this)!==get_class($record))
return false;
- $tableInfo = $this->getRecordGateway()->getRecordTableInfo($this);
+ $tableInfo = $this->getRecordTableInfo();
$pks = $tableInfo->getPrimaryKeys();
$properties = count($pks) > 0 ? $pks : $tableInfo->getColumns()->getKeys();
$equals=true;
@@ -378,7 +398,7 @@ abstract class TActiveRecord extends TComponent
/**
* @return TActiveRecordGateway record table gateway.
*/
- public static function getRecordGateway()
+ public function getRecordGateway()
{
return TActiveRecordManager::getInstance()->getRecordGateway();
}
@@ -552,6 +572,7 @@ abstract class TActiveRecord extends TComponent
{
$args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null;
$criteria = $this->getRecordCriteria($criteria,$parameters, $args);
+ $criteria->setLimit(1);
$data = $this->getRecordGateway()->findRecordsByCriteria($this,$criteria);
return $this->populateObject($data);
}
@@ -629,6 +650,7 @@ abstract class TActiveRecord extends TComponent
{
$args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null;
$criteria = $this->getRecordCriteria($sql,$parameters, $args);
+ $criteria->setLimit(1);
$data = $this->getRecordGateway()->findRecordBySql($this,$criteria);
return $this->populateObject($data);
}
@@ -1000,4 +1022,3 @@ class TActiveRecordChangeEventParameter extends TEventParameter
}
}
-?>
diff --git a/framework/Data/ActiveRecord/TActiveRecordConfig.php b/framework/Data/ActiveRecord/TActiveRecordConfig.php
index 4e21635e..63f05aef 100644
--- a/framework/Data/ActiveRecord/TActiveRecordConfig.php
+++ b/framework/Data/ActiveRecord/TActiveRecordConfig.php
@@ -105,4 +105,3 @@ class TActiveRecordConfig extends TDataSourceConfig
}
}
-?>
diff --git a/framework/Data/ActiveRecord/TActiveRecordCriteria.php b/framework/Data/ActiveRecord/TActiveRecordCriteria.php
index eec6df04..41e8ad02 100644
--- a/framework/Data/ActiveRecord/TActiveRecordCriteria.php
+++ b/framework/Data/ActiveRecord/TActiveRecordCriteria.php
@@ -37,4 +37,3 @@ class TActiveRecordCriteria extends TSqlCriteria
}
-?>
diff --git a/framework/Data/ActiveRecord/TActiveRecordGateway.php b/framework/Data/ActiveRecord/TActiveRecordGateway.php
index 23104c00..6cce9eb9 100644
--- a/framework/Data/ActiveRecord/TActiveRecordGateway.php
+++ b/framework/Data/ActiveRecord/TActiveRecordGateway.php
@@ -1,414 +1,425 @@
-<?php
-/**
- * TActiveRecordGateway, TActiveRecordStatementType, TActiveRecordEventParameter classes file.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Data.ActiveRecord
- */
-
-/**
- * TActiveRecordGateway excutes the SQL command queries and returns the data
- * record as arrays (for most finder methods).
- *
- * @author Wei Zhuo <weizho[at]gmail[dot]com>
- * @version $Id$
- * @package System.Data.ActiveRecord
- * @since 3.1
- */
-class TActiveRecordGateway extends TComponent
-{
- private $_manager;
- private $_tables=array(); //table cache
- private $_meta=array(); //meta data cache.
- private $_commandBuilders=array();
- private $_currentRecord;
-
- /**
- * Constant name for specifying optional table name in TActiveRecord.
- */
- const TABLE_CONST='TABLE';
-
- /**
- * Record gateway constructor.
- * @param TActiveRecordManager $manager
- */
- public function __construct(TActiveRecordManager $manager)
- {
- $this->_manager=$manager;
- }
-
- /**
- * @return TActiveRecordManager record manager.
- */
- protected function getManager()
- {
- return $this->_manager;
- }
-
- /**
- * Gets the table name from the 'TABLE' constant of the active record
- * class if defined, otherwise use the class name as table name.
- * @param TActiveRecord active record instance
- * @return string table name for the given record class.
- */
- protected function getRecordTableName(TActiveRecord $record)
- {
- $class = new ReflectionClass($record);
- if($class->hasConstant(self::TABLE_CONST))
- {
- $value = $class->getConstant(self::TABLE_CONST);
- if(empty($value))
- throw new TActiveRecordException('ar_invalid_tablename_property',
- get_class($record),self::TABLE_CONST);
- return $value;
- }
- else
- return strtolower(get_class($record));
- }
-
- /**
- * Returns table information, trys the application cache first.
- * @param TActiveRecord $record
- * @return TDbTableInfo table information.
- */
- public function getRecordTableInfo(TActiveRecord $record)
- {
- $tableName = $this->getRecordTableName($record);
- return $this->getTableInfo($record->getDbConnection(), $tableName);
- }
-
- /**
- * Returns table information for table in the database connection.
- * @param TDbConnection database connection
- * @param string table name
- * @return TDbTableInfo table details.
- */
- public function getTableInfo(TDbConnection $connection, $tableName)
- {
- $connStr = $connection->getConnectionString();
- $key = $connStr.$tableName;
- if(!isset($this->_tables[$key]))
- {
- //call this first to ensure that unserializing the cache
- //will find the correct driver dependent classes.
- if(!isset($this->_meta[$connStr]))
- {
- Prado::using('System.Data.Common.TDbMetaData');
- $this->_meta[$connStr] = TDbMetaData::getInstance($connection);
- }
-
- $tableInfo = null;
- if(($cache=$this->getManager()->getCache())!==null)
- $tableInfo = $cache->get($key);
- if(empty($tableInfo))
- {
- $tableInfo = $this->_meta[$connStr]->getTableInfo($tableName);
- if($cache!==null)
- $cache->set($key, $tableInfo);
- }
- $this->_tables[$key] = $tableInfo;
- }
- return $this->_tables[$key];
- }
-
- /**
- * @param TActiveRecord $record
- * @return TDataGatewayCommand
- */
- public function getCommand(TActiveRecord $record)
- {
- $conn = $record->getDbConnection();
- $connStr = $conn->getConnectionString();
- $tableInfo = $this->getRecordTableInfo($record);
- if(!isset($this->_commandBuilders[$connStr]))
- {
- $builder = $tableInfo->createCommandBuilder($record->getDbConnection());
- Prado::using('System.Data.DataGateway.TDataGatewayCommand');
- $command = new TDataGatewayCommand($builder);
- $command->OnCreateCommand[] = array($this, 'onCreateCommand');
- $command->OnExecuteCommand[] = array($this, 'onExecuteCommand');
- $this->_commandBuilders[$connStr] = $command;
-
- }
- $this->_commandBuilders[$connStr]->getBuilder()->setTableInfo($tableInfo);
- $this->_currentRecord=$record;
- return $this->_commandBuilders[$connStr];
- }
-
- /**
- * Raised when a command is prepared and parameter binding is completed.
- * The parameter object is TDataGatewayEventParameter of which the
- * {@link TDataGatewayEventParameter::getCommand Command} property can be
- * inspected to obtain the sql query to be executed.
- * This method also raises the OnCreateCommand event on the ActiveRecord
- * object calling this gateway.
- * @param TDataGatewayCommand originator $sender
- * @param TDataGatewayEventParameter
- */
- public function onCreateCommand($sender, $param)
- {
- $this->raiseEvent('OnCreateCommand', $this, $param);
- if($this->_currentRecord!==null)
- $this->_currentRecord->onCreateCommand($param);
- }
-
- /**
- * Raised when a command is executed and the result from the database was returned.
- * The parameter object is TDataGatewayResultEventParameter of which the
- * {@link TDataGatewayEventParameter::getResult Result} property contains
- * the data return from the database. The data returned can be changed
- * by setting the {@link TDataGatewayEventParameter::setResult Result} property.
- * This method also raises the OnCreateCommand event on the ActiveRecord
- * object calling this gateway.
- * @param TDataGatewayCommand originator $sender
- * @param TDataGatewayResultEventParameter
- */
- public function onExecuteCommand($sender, $param)
- {
- $this->raiseEvent('OnExecuteCommand', $this, $param);
- if($this->_currentRecord!==null)
- $this->_currentRecord->onExecuteCommand($param);
- }
-
- /**
- * Returns record data matching the given primary key(s). If the table uses
- * composite key, specify the name value pairs as an array.
- * @param TActiveRecord active record instance.
- * @param array primary name value pairs
- * @return array record data
- */
- public function findRecordByPK(TActiveRecord $record,$keys)
- {
- $command = $this->getCommand($record);
- return $command->findByPk($keys);
- }
-
- /**
- * Returns records matching the list of given primary keys.
- * @param TActiveRecord active record instance.
- * @param array list of primary name value pairs
- * @return array matching data.
- */
- public function findRecordsByPks(TActiveRecord $record, $keys)
- {
- return $this->getCommand($record)->findAllByPk($keys);
- }
-
-
- /**
- * Returns record data matching the given critera. If $iterator is true, it will
- * return multiple rows as TDbDataReader otherwise it returns the <b>first</b> row data.
- * @param TActiveRecord active record finder instance.
- * @param TActiveRecordCriteria search criteria.
- * @param boolean true to return multiple rows as iterator, false returns first row.
- * @return mixed matching data.
- */
- public function findRecordsByCriteria(TActiveRecord $record, $criteria, $iterator=false)
- {
- $command = $this->getCommand($record);
- return $iterator ? $command->findAll($criteria) : $command->find($criteria);
- }
-
- /**
- * Return record data from sql query.
- * @param TActiveRecord active record finder instance.
- * @param TActiveRecordCriteria sql query
- * @return array result.
- */
- public function findRecordBySql(TActiveRecord $record, $criteria)
- {
- return $this->getCommand($record)->findBySql($criteria);
- }
-
- /**
- * Return record data from sql query.
- * @param TActiveRecord active record finder instance.
- * @param TActiveRecordCriteria sql query
- * @return TDbDataReader result iterator.
- */
- public function findRecordsBySql(TActiveRecord $record, $criteria)
- {
- return $this->getCommand($record)->findAllBySql($criteria);
- }
-
- public function findRecordsByIndex(TActiveRecord $record, $criteria, $fields, $values)
- {
- return $this->getCommand($record)->findAllByIndex($criteria,$fields,$values);
- }
-
- /**
- * Returns the number of records that match the given criteria.
- * @param TActiveRecord active record finder instance.
- * @param TActiveRecordCriteria search criteria
- * @return int number of records.
- */
- public function countRecords(TActiveRecord $record, $criteria)
- {
- return $this->getCommand($record)->count($criteria);
- }
-
- /**
- * Insert a new record.
- * @param TActiveRecord new record.
- * @return int number of rows affected.
- */
- public function insert(TActiveRecord $record)
- {
- //$this->updateAssociatedRecords($record,true);
- $result = $this->getCommand($record)->insert($this->getInsertValues($record));
- if($result)
- $this->updatePostInsert($record);
- //$this->updateAssociatedRecords($record);
- return $result;
- }
-
- /**
- * Sets the last insert ID to the corresponding property of the record if available.
- * @param TActiveRecord record for insertion
- */
- protected function updatePostInsert($record)
- {
- $command = $this->getCommand($record);
- $tableInfo = $command->getTableInfo();
- foreach($tableInfo->getColumns() as $name => $column)
- {
- if($column->hasSequence())
- $record->setColumnValue($name,$command->getLastInsertID($column->getSequenceName()));
- }
- }
-
- /**
- * @param TActiveRecord record
- * @return array insert values.
- */
- protected function getInsertValues(TActiveRecord $record)
- {
- $values=array();
- $tableInfo = $this->getCommand($record)->getTableInfo();
- foreach($tableInfo->getColumns() as $name=>$column)
- {
- if($column->getIsExcluded())
- continue;
- $value = $record->getColumnValue($name);
- if(!$column->getAllowNull() && $value===null && !$column->hasSequence())
- {
- throw new TActiveRecordException(
- 'ar_value_must_not_be_null', get_class($record),
- $tableInfo->getTableFullName(), $name);
- }
- if($value!==null)
- $values[$name] = $value;
- }
- return $values;
- }
-
- /**
- * Update the record.
- * @param TActiveRecord dirty record.
- * @return int number of rows affected.
- */
- public function update(TActiveRecord $record)
- {
- //$this->updateAssociatedRecords($record,true);
- list($data, $keys) = $this->getUpdateValues($record);
- $result = $this->getCommand($record)->updateByPk($data, $keys);
- //$this->updateAssociatedRecords($record);
- return $result;
- }
-
- protected function getUpdateValues(TActiveRecord $record)
- {
- $values=array();
- $tableInfo = $this->getCommand($record)->getTableInfo();
- $primary=array();
- foreach($tableInfo->getColumns() as $name=>$column)
- {
- if($column->getIsExcluded())
- continue;
- $value = $record->getColumnValue($name);
- if(!$column->getAllowNull() && $value===null)
- {
- throw new TActiveRecordException(
- 'ar_value_must_not_be_null', get_class($record),
- $tableInfo->getTableFullName(), $name);
- }
- if($column->getIsPrimaryKey())
- $primary[] = $value;
- else
- $values[$name] = $value;
- }
- return array($values,$primary);
- }
-
- protected function updateAssociatedRecords(TActiveRecord $record,$updateBelongsTo=false)
- {
- $context = new TActiveRecordRelationContext($record);
- return $context->updateAssociatedRecords($updateBelongsTo);
- }
-
- /**
- * Delete the record.
- * @param TActiveRecord record to be deleted.
- * @return int number of rows affected.
- */
- public function delete(TActiveRecord $record)
- {
- return $this->getCommand($record)->deleteByPk($this->getPrimaryKeyValues($record));
- }
-
- protected function getPrimaryKeyValues(TActiveRecord $record)
- {
- $tableInfo = $this->getCommand($record)->getTableInfo();
- $primary=array();
- foreach($tableInfo->getColumns() as $name=>$column)
- {
- if($column->getIsPrimaryKey())
- $primary[$name] = $record->getColumnValue($name);
- }
- return $primary;
- }
-
- /**
- * Delete multiple records using primary keys.
- * @param TActiveRecord finder instance.
- * @return int number of rows deleted.
- */
- public function deleteRecordsByPk(TActiveRecord $record, $keys)
- {
- return $this->getCommand($record)->deleteByPk($keys);
- }
-
- /**
- * Delete multiple records by criteria.
- * @param TActiveRecord active record finder instance.
- * @param TActiveRecordCriteria search criteria
- * @return int number of records.
- */
- public function deleteRecordsByCriteria(TActiveRecord $record, $criteria)
- {
- return $this->getCommand($record)->delete($criteria);
- }
-
- /**
- * Raise the corresponding command event, insert, update, delete or select.
- * @param string command type
- * @param TDbCommand sql command to be executed.
- * @param TActiveRecord active record
- * @param TActiveRecordCriteria data for the command.
- */
- protected function raiseCommandEvent($event,$command,$record,$criteria)
- {
- if(!($criteria instanceof TSqlCriteria))
- $criteria = new TActiveRecordCriteria(null,$criteria);
- $param = new TActiveRecordEventParameter($command,$record,$criteria);
- $manager = $record->getRecordManager();
- $manager->{$event}($param);
- $record->{$event}($param);
- }
-}
-
-?>
+<?php
+/**
+ * TActiveRecordGateway, TActiveRecordStatementType, TActiveRecordEventParameter classes file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Data.ActiveRecord
+ */
+
+/**
+ * TActiveRecordGateway excutes the SQL command queries and returns the data
+ * record as arrays (for most finder methods).
+ *
+ * @author Wei Zhuo <weizho[at]gmail[dot]com>
+ * @version $Id$
+ * @package System.Data.ActiveRecord
+ * @since 3.1
+ */
+class TActiveRecordGateway extends TComponent
+{
+ private $_manager;
+ private $_tables=array(); //table cache
+ private $_meta=array(); //meta data cache.
+ private $_commandBuilders=array();
+ private $_currentRecord;
+
+ /**
+ * Constant name for specifying optional table name in TActiveRecord.
+ */
+ const TABLE_CONST='TABLE';
+ /**
+ * Method name for returning optional table name in in TActiveRecord
+ */
+ const TABLE_METHOD='table';
+
+ /**
+ * Record gateway constructor.
+ * @param TActiveRecordManager $manager
+ */
+ public function __construct(TActiveRecordManager $manager)
+ {
+ $this->_manager=$manager;
+ }
+
+ /**
+ * @return TActiveRecordManager record manager.
+ */
+ protected function getManager()
+ {
+ return $this->_manager;
+ }
+
+ /**
+ * Gets the table name from the 'TABLE' constant of the active record
+ * class if defined, otherwise use the class name as table name.
+ * @param TActiveRecord active record instance
+ * @return string table name for the given record class.
+ */
+ protected function getRecordTableName(TActiveRecord $record)
+ {
+ $class = new ReflectionClass($record);
+ if($class->hasConstant(self::TABLE_CONST))
+ {
+ $value = $class->getConstant(self::TABLE_CONST);
+ if(empty($value))
+ throw new TActiveRecordException('ar_invalid_tablename_property',
+ get_class($record),self::TABLE_CONST);
+ return $value;
+ }
+ elseif ($class->hasMethod(self::TABLE_METHOD))
+ {
+ $value = $record->{self::TABLE_METHOD}();
+ if(empty($value))
+ throw new TActiveRecordException('ar_invalid_tablename_method',
+ get_class($record),self::TABLE_METHOD);
+ return $value;
+ }
+ else
+ return strtolower(get_class($record));
+ }
+
+ /**
+ * Returns table information, trys the application cache first.
+ * @param TActiveRecord $record
+ * @return TDbTableInfo table information.
+ */
+ public function getRecordTableInfo(TActiveRecord $record)
+ {
+ $tableName = $this->getRecordTableName($record);
+ return $this->getTableInfo($record->getDbConnection(), $tableName);
+ }
+
+ /**
+ * Returns table information for table in the database connection.
+ * @param TDbConnection database connection
+ * @param string table name
+ * @return TDbTableInfo table details.
+ */
+ public function getTableInfo(TDbConnection $connection, $tableName)
+ {
+ $connStr = $connection->getConnectionString();
+ $key = $connStr.$tableName;
+ if(!isset($this->_tables[$key]))
+ {
+ //call this first to ensure that unserializing the cache
+ //will find the correct driver dependent classes.
+ if(!isset($this->_meta[$connStr]))
+ {
+ Prado::using('System.Data.Common.TDbMetaData');
+ $this->_meta[$connStr] = TDbMetaData::getInstance($connection);
+ }
+
+ $tableInfo = null;
+ if(($cache=$this->getManager()->getCache())!==null)
+ $tableInfo = $cache->get($key);
+ if(empty($tableInfo))
+ {
+ $tableInfo = $this->_meta[$connStr]->getTableInfo($tableName);
+ if($cache!==null)
+ $cache->set($key, $tableInfo);
+ }
+ $this->_tables[$key] = $tableInfo;
+ }
+ return $this->_tables[$key];
+ }
+
+ /**
+ * @param TActiveRecord $record
+ * @return TDataGatewayCommand
+ */
+ public function getCommand(TActiveRecord $record)
+ {
+ $conn = $record->getDbConnection();
+ $connStr = $conn->getConnectionString();
+ $tableInfo = $this->getRecordTableInfo($record);
+ if(!isset($this->_commandBuilders[$connStr]))
+ {
+ $builder = $tableInfo->createCommandBuilder($record->getDbConnection());
+ Prado::using('System.Data.DataGateway.TDataGatewayCommand');
+ $command = new TDataGatewayCommand($builder);
+ $command->OnCreateCommand[] = array($this, 'onCreateCommand');
+ $command->OnExecuteCommand[] = array($this, 'onExecuteCommand');
+ $this->_commandBuilders[$connStr] = $command;
+
+ }
+ $this->_commandBuilders[$connStr]->getBuilder()->setTableInfo($tableInfo);
+ $this->_currentRecord=$record;
+ return $this->_commandBuilders[$connStr];
+ }
+
+ /**
+ * Raised when a command is prepared and parameter binding is completed.
+ * The parameter object is TDataGatewayEventParameter of which the
+ * {@link TDataGatewayEventParameter::getCommand Command} property can be
+ * inspected to obtain the sql query to be executed.
+ * This method also raises the OnCreateCommand event on the ActiveRecord
+ * object calling this gateway.
+ * @param TDataGatewayCommand originator $sender
+ * @param TDataGatewayEventParameter
+ */
+ public function onCreateCommand($sender, $param)
+ {
+ $this->raiseEvent('OnCreateCommand', $this, $param);
+ if($this->_currentRecord!==null)
+ $this->_currentRecord->onCreateCommand($param);
+ }
+
+ /**
+ * Raised when a command is executed and the result from the database was returned.
+ * The parameter object is TDataGatewayResultEventParameter of which the
+ * {@link TDataGatewayEventParameter::getResult Result} property contains
+ * the data return from the database. The data returned can be changed
+ * by setting the {@link TDataGatewayEventParameter::setResult Result} property.
+ * This method also raises the OnCreateCommand event on the ActiveRecord
+ * object calling this gateway.
+ * @param TDataGatewayCommand originator $sender
+ * @param TDataGatewayResultEventParameter
+ */
+ public function onExecuteCommand($sender, $param)
+ {
+ $this->raiseEvent('OnExecuteCommand', $this, $param);
+ if($this->_currentRecord!==null)
+ $this->_currentRecord->onExecuteCommand($param);
+ }
+
+ /**
+ * Returns record data matching the given primary key(s). If the table uses
+ * composite key, specify the name value pairs as an array.
+ * @param TActiveRecord active record instance.
+ * @param array primary name value pairs
+ * @return array record data
+ */
+ public function findRecordByPK(TActiveRecord $record,$keys)
+ {
+ $command = $this->getCommand($record);
+ return $command->findByPk($keys);
+ }
+
+ /**
+ * Returns records matching the list of given primary keys.
+ * @param TActiveRecord active record instance.
+ * @param array list of primary name value pairs
+ * @return array matching data.
+ */
+ public function findRecordsByPks(TActiveRecord $record, $keys)
+ {
+ return $this->getCommand($record)->findAllByPk($keys);
+ }
+
+
+ /**
+ * Returns record data matching the given critera. If $iterator is true, it will
+ * return multiple rows as TDbDataReader otherwise it returns the <b>first</b> row data.
+ * @param TActiveRecord active record finder instance.
+ * @param TActiveRecordCriteria search criteria.
+ * @param boolean true to return multiple rows as iterator, false returns first row.
+ * @return mixed matching data.
+ */
+ public function findRecordsByCriteria(TActiveRecord $record, $criteria, $iterator=false)
+ {
+ $command = $this->getCommand($record);
+ return $iterator ? $command->findAll($criteria) : $command->find($criteria);
+ }
+
+ /**
+ * Return record data from sql query.
+ * @param TActiveRecord active record finder instance.
+ * @param TActiveRecordCriteria sql query
+ * @return array result.
+ */
+ public function findRecordBySql(TActiveRecord $record, $criteria)
+ {
+ return $this->getCommand($record)->findBySql($criteria);
+ }
+
+ /**
+ * Return record data from sql query.
+ * @param TActiveRecord active record finder instance.
+ * @param TActiveRecordCriteria sql query
+ * @return TDbDataReader result iterator.
+ */
+ public function findRecordsBySql(TActiveRecord $record, $criteria)
+ {
+ return $this->getCommand($record)->findAllBySql($criteria);
+ }
+
+ public function findRecordsByIndex(TActiveRecord $record, $criteria, $fields, $values)
+ {
+ return $this->getCommand($record)->findAllByIndex($criteria,$fields,$values);
+ }
+
+ /**
+ * Returns the number of records that match the given criteria.
+ * @param TActiveRecord active record finder instance.
+ * @param TActiveRecordCriteria search criteria
+ * @return int number of records.
+ */
+ public function countRecords(TActiveRecord $record, $criteria)
+ {
+ return $this->getCommand($record)->count($criteria);
+ }
+
+ /**
+ * Insert a new record.
+ * @param TActiveRecord new record.
+ * @return int number of rows affected.
+ */
+ public function insert(TActiveRecord $record)
+ {
+ //$this->updateAssociatedRecords($record,true);
+ $result = $this->getCommand($record)->insert($this->getInsertValues($record));
+ if($result)
+ $this->updatePostInsert($record);
+ //$this->updateAssociatedRecords($record);
+ return $result;
+ }
+
+ /**
+ * Sets the last insert ID to the corresponding property of the record if available.
+ * @param TActiveRecord record for insertion
+ */
+ protected function updatePostInsert($record)
+ {
+ $command = $this->getCommand($record);
+ $tableInfo = $command->getTableInfo();
+ foreach($tableInfo->getColumns() as $name => $column)
+ {
+ if($column->hasSequence())
+ $record->setColumnValue($name,$command->getLastInsertID($column->getSequenceName()));
+ }
+ }
+
+ /**
+ * @param TActiveRecord record
+ * @return array insert values.
+ */
+ protected function getInsertValues(TActiveRecord $record)
+ {
+ $values=array();
+ $tableInfo = $this->getCommand($record)->getTableInfo();
+ foreach($tableInfo->getColumns() as $name=>$column)
+ {
+ if($column->getIsExcluded())
+ continue;
+ $value = $record->getColumnValue($name);
+ if(!$column->getAllowNull() && $value===null && !$column->hasSequence() && !$column->getDefaultValue())
+ {
+ throw new TActiveRecordException(
+ 'ar_value_must_not_be_null', get_class($record),
+ $tableInfo->getTableFullName(), $name);
+ }
+ if($value!==null)
+ $values[$name] = $value;
+ }
+ return $values;
+ }
+
+ /**
+ * Update the record.
+ * @param TActiveRecord dirty record.
+ * @return int number of rows affected.
+ */
+ public function update(TActiveRecord $record)
+ {
+ //$this->updateAssociatedRecords($record,true);
+ list($data, $keys) = $this->getUpdateValues($record);
+ $result = $this->getCommand($record)->updateByPk($data, $keys);
+ //$this->updateAssociatedRecords($record);
+ return $result;
+ }
+
+ protected function getUpdateValues(TActiveRecord $record)
+ {
+ $values=array();
+ $tableInfo = $this->getCommand($record)->getTableInfo();
+ $primary=array();
+ foreach($tableInfo->getColumns() as $name=>$column)
+ {
+ if($column->getIsExcluded())
+ continue;
+ $value = $record->getColumnValue($name);
+ if(!$column->getAllowNull() && $value===null)
+ {
+ throw new TActiveRecordException(
+ 'ar_value_must_not_be_null', get_class($record),
+ $tableInfo->getTableFullName(), $name);
+ }
+ if($column->getIsPrimaryKey())
+ $primary[] = $value;
+ else
+ $values[$name] = $value;
+ }
+ return array($values,$primary);
+ }
+
+ protected function updateAssociatedRecords(TActiveRecord $record,$updateBelongsTo=false)
+ {
+ $context = new TActiveRecordRelationContext($record);
+ return $context->updateAssociatedRecords($updateBelongsTo);
+ }
+
+ /**
+ * Delete the record.
+ * @param TActiveRecord record to be deleted.
+ * @return int number of rows affected.
+ */
+ public function delete(TActiveRecord $record)
+ {
+ return $this->getCommand($record)->deleteByPk($this->getPrimaryKeyValues($record));
+ }
+
+ protected function getPrimaryKeyValues(TActiveRecord $record)
+ {
+ $tableInfo = $this->getCommand($record)->getTableInfo();
+ $primary=array();
+ foreach($tableInfo->getColumns() as $name=>$column)
+ {
+ if($column->getIsPrimaryKey())
+ $primary[$name] = $record->getColumnValue($name);
+ }
+ return $primary;
+ }
+
+ /**
+ * Delete multiple records using primary keys.
+ * @param TActiveRecord finder instance.
+ * @return int number of rows deleted.
+ */
+ public function deleteRecordsByPk(TActiveRecord $record, $keys)
+ {
+ return $this->getCommand($record)->deleteByPk($keys);
+ }
+
+ /**
+ * Delete multiple records by criteria.
+ * @param TActiveRecord active record finder instance.
+ * @param TActiveRecordCriteria search criteria
+ * @return int number of records.
+ */
+ public function deleteRecordsByCriteria(TActiveRecord $record, $criteria)
+ {
+ return $this->getCommand($record)->delete($criteria);
+ }
+
+ /**
+ * Raise the corresponding command event, insert, update, delete or select.
+ * @param string command type
+ * @param TDbCommand sql command to be executed.
+ * @param TActiveRecord active record
+ * @param TActiveRecordCriteria data for the command.
+ */
+ protected function raiseCommandEvent($event,$command,$record,$criteria)
+ {
+ if(!($criteria instanceof TSqlCriteria))
+ $criteria = new TActiveRecordCriteria(null,$criteria);
+ $param = new TActiveRecordEventParameter($command,$record,$criteria);
+ $manager = $record->getRecordManager();
+ $manager->{$event}($param);
+ $record->{$event}($param);
+ }
+}
+
diff --git a/framework/Data/ActiveRecord/TActiveRecordManager.php b/framework/Data/ActiveRecord/TActiveRecordManager.php
index ce14ac4d..9912e7ff 100644
--- a/framework/Data/ActiveRecord/TActiveRecordManager.php
+++ b/framework/Data/ActiveRecord/TActiveRecordManager.php
@@ -109,4 +109,3 @@ class TActiveRecordManager extends TComponent
}
-?>
diff --git a/framework/Data/Common/IbmDb2/TIbmColumnMetaData.php b/framework/Data/Common/IbmDb2/TIbmColumnMetaData.php
index ee87a374..3b7001ab 100644
--- a/framework/Data/Common/IbmDb2/TIbmColumnMetaData.php
+++ b/framework/Data/Common/IbmDb2/TIbmColumnMetaData.php
@@ -154,4 +154,3 @@ class TIbmColumnMetaData extends TComponent
}
-?>
diff --git a/framework/Data/Common/IbmDb2/TIbmMetaData.php b/framework/Data/Common/IbmDb2/TIbmMetaData.php
index 059ef2d5..496bb12f 100644
--- a/framework/Data/Common/IbmDb2/TIbmMetaData.php
+++ b/framework/Data/Common/IbmDb2/TIbmMetaData.php
@@ -110,4 +110,3 @@ class TIbmMetaData extends TDbMetaDataCommon
}
-?>
diff --git a/framework/Data/Common/IbmDb2/TIbmMetaDataInspector.php b/framework/Data/Common/IbmDb2/TIbmMetaDataInspector.php
index cfb4803d..a37fad6e 100644
--- a/framework/Data/Common/IbmDb2/TIbmMetaDataInspector.php
+++ b/framework/Data/Common/IbmDb2/TIbmMetaDataInspector.php
@@ -110,4 +110,3 @@ class TIbmMetaDataInspector extends TDbMetaDataInspector
return new TIbmMetaData($table,$columns,$pks);
}
}
-?>
diff --git a/framework/Data/Common/Mssql/TMssqlCommandBuilder.php b/framework/Data/Common/Mssql/TMssqlCommandBuilder.php
index 75d98198..1a0ad4ce 100644
--- a/framework/Data/Common/Mssql/TMssqlCommandBuilder.php
+++ b/framework/Data/Common/Mssql/TMssqlCommandBuilder.php
@@ -170,4 +170,3 @@ class TMssqlCommandBuilder extends TDbCommandBuilder
}
}
-?>
diff --git a/framework/Data/Common/Mssql/TMssqlMetaData.php b/framework/Data/Common/Mssql/TMssqlMetaData.php
index faa94e69..8309e4ec 100644
--- a/framework/Data/Common/Mssql/TMssqlMetaData.php
+++ b/framework/Data/Common/Mssql/TMssqlMetaData.php
@@ -232,4 +232,3 @@ EOD;
}
}
-?>
diff --git a/framework/Data/Common/Mssql/TMssqlTableColumn.php b/framework/Data/Common/Mssql/TMssqlTableColumn.php
index 5f41f429..8a291b52 100644
--- a/framework/Data/Common/Mssql/TMssqlTableColumn.php
+++ b/framework/Data/Common/Mssql/TMssqlTableColumn.php
@@ -62,4 +62,3 @@ class TMssqlTableColumn extends TDbTableColumn
}
}
-?>
diff --git a/framework/Data/Common/Mssql/TMssqlTableInfo.php b/framework/Data/Common/Mssql/TMssqlTableInfo.php
index 3a2ae033..356c6f26 100644
--- a/framework/Data/Common/Mssql/TMssqlTableInfo.php
+++ b/framework/Data/Common/Mssql/TMssqlTableInfo.php
@@ -62,4 +62,3 @@ class TMssqlTableInfo extends TDbTableInfo
}
}
-?>
diff --git a/framework/Data/Common/Mysql/TMysqlCommandBuilder.php b/framework/Data/Common/Mysql/TMysqlCommandBuilder.php
index b296a82d..3326851f 100644
--- a/framework/Data/Common/Mysql/TMysqlCommandBuilder.php
+++ b/framework/Data/Common/Mysql/TMysqlCommandBuilder.php
@@ -24,4 +24,3 @@ class TMysqlCommandBuilder extends TDbCommandBuilder
{
}
-?>
diff --git a/framework/Data/Common/Mysql/TMysqlMetaData.php b/framework/Data/Common/Mysql/TMysqlMetaData.php
index aaebd8dc..75f7a7cf 100644
--- a/framework/Data/Common/Mysql/TMysqlMetaData.php
+++ b/framework/Data/Common/Mysql/TMysqlMetaData.php
@@ -246,7 +246,9 @@ class TMysqlMetaData extends TDbMetaData
if($row['Key_name']==='PRIMARY')
$primary[] = $row['Column_name'];
}
- if($this->getServerVersion() > 5)
+ // MySQL version was increased to >=5.1.21 instead of 5.x
+ // due to a MySQL bug (http://bugs.mysql.com/bug.php?id=19588)
+ if($this->getServerVersion() >= 5.121)
$foreign = $this->getForeignConstraints($schemaName,$tableName);
else
$foreign = $this->findForeignConstraints($schemaName,$tableName);
@@ -352,4 +354,3 @@ EOD;
}
}
-?>
diff --git a/framework/Data/Common/Mysql/TMysqlTableColumn.php b/framework/Data/Common/Mysql/TMysqlTableColumn.php
index 99b4333a..5f4351a7 100644
--- a/framework/Data/Common/Mysql/TMysqlTableColumn.php
+++ b/framework/Data/Common/Mysql/TMysqlTableColumn.php
@@ -70,4 +70,3 @@ class TMysqlTableColumn extends TDbTableColumn
}
}
-?>
diff --git a/framework/Data/Common/Pgsql/TPgsqlCommandBuilder.php b/framework/Data/Common/Pgsql/TPgsqlCommandBuilder.php
index 460da46a..4cae8b89 100644
--- a/framework/Data/Common/Pgsql/TPgsqlCommandBuilder.php
+++ b/framework/Data/Common/Pgsql/TPgsqlCommandBuilder.php
@@ -67,4 +67,3 @@ class TPgsqlCommandBuilder extends TDbCommandBuilder
}
-?>
diff --git a/framework/Data/Common/Pgsql/TPgsqlMetaData.php b/framework/Data/Common/Pgsql/TPgsqlMetaData.php
index 45d55086..a2243531 100644
--- a/framework/Data/Common/Pgsql/TPgsqlMetaData.php
+++ b/framework/Data/Common/Pgsql/TPgsqlMetaData.php
@@ -390,4 +390,3 @@ EOD;
}
}
-?>
diff --git a/framework/Data/Common/Pgsql/TPgsqlTableColumn.php b/framework/Data/Common/Pgsql/TPgsqlTableColumn.php
index 7ec2312a..562e2c56 100644
--- a/framework/Data/Common/Pgsql/TPgsqlTableColumn.php
+++ b/framework/Data/Common/Pgsql/TPgsqlTableColumn.php
@@ -47,4 +47,3 @@ class TPgsqlTableColumn extends TDbTableColumn
}
}
-?>
diff --git a/framework/Data/Common/Pgsql/TPgsqlTableInfo.php b/framework/Data/Common/Pgsql/TPgsqlTableInfo.php
index 2a3a8461..2447c141 100644
--- a/framework/Data/Common/Pgsql/TPgsqlTableInfo.php
+++ b/framework/Data/Common/Pgsql/TPgsqlTableInfo.php
@@ -56,4 +56,3 @@ class TPgsqlTableInfo extends TDbTableInfo
}
}
-?>
diff --git a/framework/Data/Common/Sqlite/TSqliteCommandBuilder.php b/framework/Data/Common/Sqlite/TSqliteCommandBuilder.php
index c02ed76d..c60e17a3 100644
--- a/framework/Data/Common/Sqlite/TSqliteCommandBuilder.php
+++ b/framework/Data/Common/Sqlite/TSqliteCommandBuilder.php
@@ -45,4 +45,3 @@ class TSqliteCommandBuilder extends TDbCommandBuilder
}
}
-?>
diff --git a/framework/Data/Common/Sqlite/TSqliteMetaData.php b/framework/Data/Common/Sqlite/TSqliteMetaData.php
index c562c930..010a2148 100644
--- a/framework/Data/Common/Sqlite/TSqliteMetaData.php
+++ b/framework/Data/Common/Sqlite/TSqliteMetaData.php
@@ -178,4 +178,3 @@ CREATE TABLE bar
);
*/
-?>
diff --git a/framework/Data/Common/Sqlite/TSqliteTableColumn.php b/framework/Data/Common/Sqlite/TSqliteTableColumn.php
index 3c9100ab..4e79de6d 100644
--- a/framework/Data/Common/Sqlite/TSqliteTableColumn.php
+++ b/framework/Data/Common/Sqlite/TSqliteTableColumn.php
@@ -62,4 +62,3 @@ class TSqliteTableColumn extends TDbTableColumn
}
}
-?>
diff --git a/framework/Data/Common/Sqlite/TSqliteTableInfo.php b/framework/Data/Common/Sqlite/TSqliteTableInfo.php
index 95c3fe02..b729a593 100644
--- a/framework/Data/Common/Sqlite/TSqliteTableInfo.php
+++ b/framework/Data/Common/Sqlite/TSqliteTableInfo.php
@@ -45,4 +45,3 @@ class TSqliteTableInfo extends TDbTableInfo
}
}
-?>
diff --git a/framework/Data/Common/TDbMetaData.php b/framework/Data/Common/TDbMetaData.php
index c0f10d41..bcdf0e46 100644
--- a/framework/Data/Common/TDbMetaData.php
+++ b/framework/Data/Common/TDbMetaData.php
@@ -121,4 +121,3 @@ abstract class TDbMetaData extends TComponent
}
}
-?>
diff --git a/framework/Data/Common/TDbTableColumn.php b/framework/Data/Common/TDbTableColumn.php
index b3d603ae..3bb9454b 100644
--- a/framework/Data/Common/TDbTableColumn.php
+++ b/framework/Data/Common/TDbTableColumn.php
@@ -197,4 +197,3 @@ class TDbTableColumn extends TComponent
}
}
-?>
diff --git a/framework/Data/Common/TDbTableInfo.php b/framework/Data/Common/TDbTableInfo.php
index 87af2234..e2aae3d0 100644
--- a/framework/Data/Common/TDbTableInfo.php
+++ b/framework/Data/Common/TDbTableInfo.php
@@ -156,4 +156,3 @@ class TDbTableInfo extends TComponent
}
}
-?>
diff --git a/framework/Data/DataGateway/TTableGateway.php b/framework/Data/DataGateway/TTableGateway.php
index 0f2644be..163efcf5 100644
--- a/framework/Data/DataGateway/TTableGateway.php
+++ b/framework/Data/DataGateway/TTableGateway.php
@@ -474,4 +474,3 @@ class TTableGateway extends TComponent
}
}
-?>
diff --git a/framework/Data/SqlMap/Configuration/TDiscriminator.php b/framework/Data/SqlMap/Configuration/TDiscriminator.php
index 75ce2352..747c4158 100644
--- a/framework/Data/SqlMap/Configuration/TDiscriminator.php
+++ b/framework/Data/SqlMap/Configuration/TDiscriminator.php
@@ -230,4 +230,3 @@ class TSubMap extends TComponent
}
}
-?>
diff --git a/framework/Data/SqlMap/Configuration/TInlineParameterMapParser.php b/framework/Data/SqlMap/Configuration/TInlineParameterMapParser.php
index d29d5f27..2e8f38d6 100644
--- a/framework/Data/SqlMap/Configuration/TInlineParameterMapParser.php
+++ b/framework/Data/SqlMap/Configuration/TInlineParameterMapParser.php
@@ -27,7 +27,7 @@ class TInlineParameterMapParser
/**
* Regular expression for parsing inline parameter maps.
*/
- const PARAMETER_TOKEN_REGEXP = '/#(#?[^#]+#?)#/';
+ const PARAMETER_TOKEN_REGEXP = '/#([^#]+)#/';
/**
* Parse the sql text for inline parameters.
@@ -77,4 +77,3 @@ class TInlineParameterMapParser
}
}
-?>
diff --git a/framework/Data/SqlMap/Configuration/TParameterMap.php b/framework/Data/SqlMap/Configuration/TParameterMap.php
index 117c6037..f4fbbe1c 100644
--- a/framework/Data/SqlMap/Configuration/TParameterMap.php
+++ b/framework/Data/SqlMap/Configuration/TParameterMap.php
@@ -205,4 +205,3 @@ class TParameterMap extends TComponent
return $value;
}
}
-?>
diff --git a/framework/Data/SqlMap/Configuration/TParameterProperty.php b/framework/Data/SqlMap/Configuration/TParameterProperty.php
index d0af3a75..dcea754c 100644
--- a/framework/Data/SqlMap/Configuration/TParameterProperty.php
+++ b/framework/Data/SqlMap/Configuration/TParameterProperty.php
@@ -136,4 +136,3 @@ class TParameterProperty extends TComponent
}
}
-?>
diff --git a/framework/Data/SqlMap/Configuration/TResultMap.php b/framework/Data/SqlMap/Configuration/TResultMap.php
index 168041d2..d59d9522 100644
--- a/framework/Data/SqlMap/Configuration/TResultMap.php
+++ b/framework/Data/SqlMap/Configuration/TResultMap.php
@@ -198,4 +198,3 @@ class TResultMap extends TComponent
}
}
-?>
diff --git a/framework/Data/SqlMap/Configuration/TResultProperty.php b/framework/Data/SqlMap/Configuration/TResultProperty.php
index 711fa7a0..8e20d5e4 100644
--- a/framework/Data/SqlMap/Configuration/TResultProperty.php
+++ b/framework/Data/SqlMap/Configuration/TResultProperty.php
@@ -326,4 +326,3 @@ class TResultProperty extends TComponent
}
}
-?>
diff --git a/framework/Data/SqlMap/Configuration/TSimpleDynamicParser.php b/framework/Data/SqlMap/Configuration/TSimpleDynamicParser.php
index 6df8cefd..9a9b1277 100644
--- a/framework/Data/SqlMap/Configuration/TSimpleDynamicParser.php
+++ b/framework/Data/SqlMap/Configuration/TSimpleDynamicParser.php
@@ -43,4 +43,3 @@ class TSimpleDynamicParser
}
}
-?>
diff --git a/framework/Data/SqlMap/Configuration/TSqlMapCacheModel.php b/framework/Data/SqlMap/Configuration/TSqlMapCacheModel.php
index edb78ea7..d7984dc4 100644
--- a/framework/Data/SqlMap/Configuration/TSqlMapCacheModel.php
+++ b/framework/Data/SqlMap/Configuration/TSqlMapCacheModel.php
@@ -214,4 +214,3 @@ class TSqlMapCacheKey
}
}
-?>
diff --git a/framework/Data/SqlMap/Configuration/TSqlMapStatement.php b/framework/Data/SqlMap/Configuration/TSqlMapStatement.php
index 77b714fd..3afcc75f 100644
--- a/framework/Data/SqlMap/Configuration/TSqlMapStatement.php
+++ b/framework/Data/SqlMap/Configuration/TSqlMapStatement.php
@@ -428,4 +428,3 @@ class TSqlMapSelectKey extends TSqlMapStatement
}
}
-?>
diff --git a/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php b/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php
index d0c57d57..f2d13966 100644
--- a/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php
+++ b/framework/Data/SqlMap/Configuration/TSqlMapXmlConfiguration.php
@@ -309,6 +309,16 @@ class TSqlMapXmlMappingConfiguration extends TSqlMapXmlConfigBuilder
private $_FlushOnExecuteStatements=array();
+ /**
+ * Regular expressions for escaping simple/inline parameter symbols
+ */
+ const SIMPLE_MARK='$';
+ const INLINE_SYMBOL='#';
+ const ESCAPED_SIMPLE_MARK_REGEXP='/\$\$/';
+ const ESCAPED_INLINE_SYMBOL_REGEXP='/\#\#/';
+ const SIMPLE_PLACEHOLDER='`!!`';
+ const INLINE_PLACEHOLDER='`!!!`';
+
/**
* @param TSqlMapXmlConfiguration parent xml configuration.
*/
@@ -532,6 +542,7 @@ class TSqlMapXmlMappingConfiguration extends TSqlMapXmlConfigBuilder
$scope['file'] = $this->_configFile;
$scope['node'] = $node;
+ $sqlStatement=preg_replace(self::ESCAPED_INLINE_SYMBOL_REGEXP,self::INLINE_PLACEHOLDER,$sqlStatement);
if($statement->parameterMap() === null)
{
// Build a Parametermap with the inline parameters.
@@ -548,6 +559,7 @@ class TSqlMapXmlMappingConfiguration extends TSqlMapXmlConfigBuilder
}
$sqlStatement = $sqlText['sql'];
}
+ $sqlStatement=preg_replace('/'.self::INLINE_PLACEHOLDER.'/',self::INLINE_SYMBOL,$sqlStatement);
$this->prepareSql($statement, $sqlStatement, $node);
}
@@ -562,6 +574,7 @@ class TSqlMapXmlMappingConfiguration extends TSqlMapXmlConfigBuilder
protected function prepareSql($statement,$sqlStatement, $node)
{
$simpleDynamic = new TSimpleDynamicParser;
+ $sqlStatement=preg_replace(self::ESCAPED_SIMPLE_MARK_REGEXP,self::SIMPLE_PLACEHOLDER,$sqlStatement);
$dynamics = $simpleDynamic->parse($sqlStatement);
if(count($dynamics['parameters']) > 0)
{
@@ -570,6 +583,7 @@ class TSqlMapXmlMappingConfiguration extends TSqlMapXmlConfigBuilder
}
else
$sql = new TStaticSql();
+ $sqlStatement=preg_replace('/'.self::SIMPLE_PLACEHOLDER.'/',self::SIMPLE_MARK,$sqlStatement);
$sql->buildPreparedStatement($statement, $sqlStatement);
$statement->setSqlText($sql);
}
@@ -724,4 +738,3 @@ class TSqlMapXmlMappingConfiguration extends TSqlMapXmlConfigBuilder
}
}
-?>
diff --git a/framework/Data/SqlMap/DataMapper/TLazyLoadList.php b/framework/Data/SqlMap/DataMapper/TLazyLoadList.php
index 02b08e8e..69b20bf6 100644
--- a/framework/Data/SqlMap/DataMapper/TLazyLoadList.php
+++ b/framework/Data/SqlMap/DataMapper/TLazyLoadList.php
@@ -142,4 +142,3 @@ class TObjectProxy
}
}
-?>
diff --git a/framework/Data/SqlMap/DataMapper/TPropertyAccess.php b/framework/Data/SqlMap/DataMapper/TPropertyAccess.php
index 23e854ac..a27cb50f 100644
--- a/framework/Data/SqlMap/DataMapper/TPropertyAccess.php
+++ b/framework/Data/SqlMap/DataMapper/TPropertyAccess.php
@@ -106,7 +106,8 @@ class TPropertyAccess
$object = $object->{$getter}();
else if(in_array($prop, array_keys(get_object_vars($object))))
$object = $object->{$prop};
- return false;
+ else
+ return false;
}
else
return false;
diff --git a/framework/Data/SqlMap/DataMapper/TSqlMapCache.php b/framework/Data/SqlMap/DataMapper/TSqlMapCache.php
index 61c5bb95..05b72e08 100644
--- a/framework/Data/SqlMap/DataMapper/TSqlMapCache.php
+++ b/framework/Data/SqlMap/DataMapper/TSqlMapCache.php
@@ -225,4 +225,3 @@ class TSqlMapApplicationCache implements ICache
}
}
-?>
diff --git a/framework/Data/SqlMap/DataMapper/TSqlMapException.php b/framework/Data/SqlMap/DataMapper/TSqlMapException.php
index 69a0b0cd..0bf0ac32 100644
--- a/framework/Data/SqlMap/DataMapper/TSqlMapException.php
+++ b/framework/Data/SqlMap/DataMapper/TSqlMapException.php
@@ -113,4 +113,3 @@ class TSqlMapExecutionException extends TSqlMapException
{
}
-?>
diff --git a/framework/Data/SqlMap/DataMapper/TSqlMapPagedList.php b/framework/Data/SqlMap/DataMapper/TSqlMapPagedList.php
index b3a88653..86171c1e 100644
--- a/framework/Data/SqlMap/DataMapper/TSqlMapPagedList.php
+++ b/framework/Data/SqlMap/DataMapper/TSqlMapPagedList.php
@@ -206,4 +206,3 @@ class TSqlMapPagedList extends TPagedList
}
}
-?>
diff --git a/framework/Data/SqlMap/DataMapper/TSqlMapTypeHandlerRegistry.php b/framework/Data/SqlMap/DataMapper/TSqlMapTypeHandlerRegistry.php
index aa39dce1..05866395 100644
--- a/framework/Data/SqlMap/DataMapper/TSqlMapTypeHandlerRegistry.php
+++ b/framework/Data/SqlMap/DataMapper/TSqlMapTypeHandlerRegistry.php
@@ -190,4 +190,3 @@ abstract class TSqlMapTypeHandler extends TComponent
public abstract function createNewInstance($row=null);
}
-?>
diff --git a/framework/Data/SqlMap/Statements/IMappedStatement.php b/framework/Data/SqlMap/Statements/IMappedStatement.php
index 94189420..dc628c9e 100644
--- a/framework/Data/SqlMap/Statements/IMappedStatement.php
+++ b/framework/Data/SqlMap/Statements/IMappedStatement.php
@@ -80,4 +80,3 @@ interface IMappedStatement
public function executeQueryForObject($connection,$parameter, $result=null);
}
-?>
diff --git a/framework/Data/SqlMap/Statements/TCachingStatement.php b/framework/Data/SqlMap/Statements/TCachingStatement.php
index 7c9498d4..c8a748c1 100644
--- a/framework/Data/SqlMap/Statements/TCachingStatement.php
+++ b/framework/Data/SqlMap/Statements/TCachingStatement.php
@@ -106,4 +106,3 @@ class TCachingStatement implements IMappedStatement
}
}
-?>
diff --git a/framework/Data/SqlMap/Statements/TDeleteMappedStatement.php b/framework/Data/SqlMap/Statements/TDeleteMappedStatement.php
index bb95cab9..1a3d738a 100644
--- a/framework/Data/SqlMap/Statements/TDeleteMappedStatement.php
+++ b/framework/Data/SqlMap/Statements/TDeleteMappedStatement.php
@@ -22,4 +22,3 @@ class TDeleteMappedStatement extends TUpdateMappedStatement
{
}
-?>
diff --git a/framework/Data/SqlMap/Statements/TInsertMappedStatement.php b/framework/Data/SqlMap/Statements/TInsertMappedStatement.php
index 28ade045..1efb5b6b 100644
--- a/framework/Data/SqlMap/Statements/TInsertMappedStatement.php
+++ b/framework/Data/SqlMap/Statements/TInsertMappedStatement.php
@@ -47,4 +47,3 @@ class TInsertMappedStatement extends TMappedStatement
}
}
-?>
diff --git a/framework/Data/SqlMap/Statements/TMappedStatement.php b/framework/Data/SqlMap/Statements/TMappedStatement.php
index 2feeba90..6a9130fe 100644
--- a/framework/Data/SqlMap/Statements/TMappedStatement.php
+++ b/framework/Data/SqlMap/Statements/TMappedStatement.php
@@ -4,7 +4,7 @@
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Data.SqlMap.Statements
@@ -561,7 +561,7 @@ class TMappedStatement extends TComponent implements IMappedStatement
else
$obj = $this->fillDefaultResultMap(null, $row, $resultObject);
if(class_exists('TActiveRecord',false) && $obj instanceof TActiveRecord)
- //Create a new clean active record.
+ //Create a new clean active record.
$obj=TActiveRecord::createRecord(get_class($obj),$obj);
return $obj;
}
@@ -1115,7 +1115,7 @@ class TSqlMapObjectCollectionTree
else if(is_array($list))
$list[] = $this->_entries[$node]['object'];
else
- throw TSqlMapExecutionException(
+ throw new TSqlMapExecutionException(
'sqlmap_property_must_be_list');
}
@@ -1216,4 +1216,3 @@ class TResultSetMapItemParameter extends TComponent
}
}
-?>
diff --git a/framework/Data/SqlMap/Statements/TPreparedCommand.php b/framework/Data/SqlMap/Statements/TPreparedCommand.php
index 76407190..99bb6eff 100644
--- a/framework/Data/SqlMap/Statements/TPreparedCommand.php
+++ b/framework/Data/SqlMap/Statements/TPreparedCommand.php
@@ -58,4 +58,3 @@ class TPreparedCommand
}
}
-?>
diff --git a/framework/Data/SqlMap/Statements/TPreparedStatement.php b/framework/Data/SqlMap/Statements/TPreparedStatement.php
index be005e81..7d862378 100644
--- a/framework/Data/SqlMap/Statements/TPreparedStatement.php
+++ b/framework/Data/SqlMap/Statements/TPreparedStatement.php
@@ -41,4 +41,3 @@ class TPreparedStatement extends TComponent
}
-?>
diff --git a/framework/Data/SqlMap/Statements/TPreparedStatementFactory.php b/framework/Data/SqlMap/Statements/TPreparedStatementFactory.php
index 5c3e2f22..44603408 100644
--- a/framework/Data/SqlMap/Statements/TPreparedStatementFactory.php
+++ b/framework/Data/SqlMap/Statements/TPreparedStatementFactory.php
@@ -47,4 +47,3 @@ class TPreparedStatementFactory
}
}
-?>
diff --git a/framework/Data/SqlMap/Statements/TSelectMappedStatement.php b/framework/Data/SqlMap/Statements/TSelectMappedStatement.php
index a8253536..1802db2f 100644
--- a/framework/Data/SqlMap/Statements/TSelectMappedStatement.php
+++ b/framework/Data/SqlMap/Statements/TSelectMappedStatement.php
@@ -34,4 +34,3 @@ class TSelectMappedStatement extends TMappedStatement
}
-?>
diff --git a/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php b/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php
index 38554778..910fd659 100644
--- a/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php
+++ b/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php
@@ -47,4 +47,3 @@ class TSimpleDynamicSql extends TStaticSql
}
}
-?>
diff --git a/framework/Data/SqlMap/Statements/TStaticSql.php b/framework/Data/SqlMap/Statements/TStaticSql.php
index 8f4687df..eba54ed7 100644
--- a/framework/Data/SqlMap/Statements/TStaticSql.php
+++ b/framework/Data/SqlMap/Statements/TStaticSql.php
@@ -34,4 +34,3 @@ class TStaticSql extends TComponent
}
}
-?>
diff --git a/framework/Data/SqlMap/Statements/TUpdateMappedStatement.php b/framework/Data/SqlMap/Statements/TUpdateMappedStatement.php
index c0aa798e..633ec797 100644
--- a/framework/Data/SqlMap/Statements/TUpdateMappedStatement.php
+++ b/framework/Data/SqlMap/Statements/TUpdateMappedStatement.php
@@ -47,4 +47,3 @@ class TUpdateMappedStatement extends TMappedStatement
}
}
-?>
diff --git a/framework/Data/SqlMap/TSqlMapConfig.php b/framework/Data/SqlMap/TSqlMapConfig.php
index 5a779dda..98f2a844 100644
--- a/framework/Data/SqlMap/TSqlMapConfig.php
+++ b/framework/Data/SqlMap/TSqlMapConfig.php
@@ -162,4 +162,3 @@ class TSqlMapConfig extends TDataSourceConfig
}
}
-?>
diff --git a/framework/Data/SqlMap/TSqlMapGateway.php b/framework/Data/SqlMap/TSqlMapGateway.php
index dd7c2069..97b31b50 100644
--- a/framework/Data/SqlMap/TSqlMapGateway.php
+++ b/framework/Data/SqlMap/TSqlMapGateway.php
@@ -259,4 +259,3 @@ class TSqlMapGateway extends TComponent
}
}
-?>
diff --git a/framework/Data/SqlMap/TSqlMapManager.php b/framework/Data/SqlMap/TSqlMapManager.php
index 62c2de20..290050d1 100644
--- a/framework/Data/SqlMap/TSqlMapManager.php
+++ b/framework/Data/SqlMap/TSqlMapManager.php
@@ -258,4 +258,3 @@ class TSqlMapManager extends TComponent
}
}
-?>
diff --git a/framework/Data/TDataSourceConfig.php b/framework/Data/TDataSourceConfig.php
index 804ea848..9e6bb2fc 100644
--- a/framework/Data/TDataSourceConfig.php
+++ b/framework/Data/TDataSourceConfig.php
@@ -165,5 +165,3 @@ class TDataSourceConfig extends TModule
throw new TConfigurationException('datasource_dbconnection_invalid',$id);
}
}
-
-?>
diff --git a/framework/Data/TDbCommand.php b/framework/Data/TDbCommand.php
index c48e7ded..d09c53f4 100644
--- a/framework/Data/TDbCommand.php
+++ b/framework/Data/TDbCommand.php
@@ -305,4 +305,3 @@ class TDbCommand extends TComponent
}
}
-?>
diff --git a/framework/Data/TDbConnection.php b/framework/Data/TDbConnection.php
index 5489c7fd..259ca7b7 100644
--- a/framework/Data/TDbConnection.php
+++ b/framework/Data/TDbConnection.php
@@ -167,9 +167,11 @@ class TDbConnection extends TComponent
try
{
$this->_pdo=new PDO($this->getConnectionString(),$this->getUsername(),
- $this->getPassword(),$this->_attributes);
+ $this->getPassword(),$this->_attributes);
+ // This attribute is only useful for PDO::MySql driver.
+ // Ignore the warning if a driver doesn't understand this.
+ @$this->_pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $this->_pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$this->_active=true;
$this->setConnectionCharset();
}
diff --git a/framework/Data/TDbDataReader.php b/framework/Data/TDbDataReader.php
index 65fc363d..7b54414e 100644
--- a/framework/Data/TDbDataReader.php
+++ b/framework/Data/TDbDataReader.php
@@ -223,4 +223,3 @@ class TDbDataReader extends TComponent implements Iterator
}
}
-?>
diff --git a/framework/Data/TDbTransaction.php b/framework/Data/TDbTransaction.php
index 5a19cacf..60b14a55 100644
--- a/framework/Data/TDbTransaction.php
+++ b/framework/Data/TDbTransaction.php
@@ -110,4 +110,3 @@ class TDbTransaction extends TComponent
}
}
-?>