summaryrefslogtreecommitdiff
path: root/framework/Data/DataGateway
diff options
context:
space:
mode:
authorwei <>2007-04-14 05:02:29 +0000
committerwei <>2007-04-14 05:02:29 +0000
commit0f0d3c62e608287cdf77f1a3239371b521ecb40b (patch)
treebd91a9499a946e1667a0e17a9c5a97a9d695c7ce /framework/Data/DataGateway
parentb05442bbe751b87998d8500ad8e6b28d652a35db (diff)
Refactor ActiveRecordGateway to use TDataGatewayCommand
Diffstat (limited to 'framework/Data/DataGateway')
-rw-r--r--framework/Data/DataGateway/TDataGatewayCommand.php23
1 files changed, 15 insertions, 8 deletions
diff --git a/framework/Data/DataGateway/TDataGatewayCommand.php b/framework/Data/DataGateway/TDataGatewayCommand.php
index a5f729d8..8a340ee7 100644
--- a/framework/Data/DataGateway/TDataGatewayCommand.php
+++ b/framework/Data/DataGateway/TDataGatewayCommand.php
@@ -15,7 +15,7 @@ class TDataGatewayCommand extends TComponent
/**
* @return TDbTableInfo
*/
- protected function getTableInfo()
+ public function getTableInfo()
{
return $this->_builder->getTableInfo();
}
@@ -23,7 +23,7 @@ class TDataGatewayCommand extends TComponent
/**
* @return TDbConnection
*/
- protected function getDbConnection()
+ public function getDbConnection()
{
return $this->_builder->getDbConnection();
}
@@ -31,7 +31,7 @@ class TDataGatewayCommand extends TComponent
/**
* @return TDbCommandBuilder
*/
- protected function getBuilder()
+ public function getBuilder()
{
return $this->_builder;
}
@@ -66,6 +66,17 @@ class TDataGatewayCommand extends TComponent
}
/**
+ * @param array update for update
+ * @param array primary key-value name pairs.
+ * @return integer number of records affected.
+ */
+ public function updateByPk($data, $keys)
+ {
+ list($where, $parameters) = $this->getPrimaryKeyCondition((array)$keys);
+ return $this->update($data, new TSqlCriteria($where, $parameters));
+ }
+
+ /**
* Find one record matching the critera.
* @param TSqlCriteria find conditions and parameters.
* @return array matching record.
@@ -281,11 +292,7 @@ class TDataGatewayCommand extends TComponent
*/
public function getLastInsertID()
{
- foreach($this->getTableInfo()->getColumns() as $column)
- {
- if($column->hasSequence())
- return $this->getDbConnection()->getLastInsertID($column->getSequenceName());
- }
+ return $this->getBuilder()->getLastInsertID();
}
/**