diff options
Diffstat (limited to 'framework/Data/DataGateway/TDataGatewayCommand.php')
-rw-r--r-- | framework/Data/DataGateway/TDataGatewayCommand.php | 23 |
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();
}
/**
|