summaryrefslogtreecommitdiff
path: root/framework/Data/ActiveRecord/Vendor/TDbMetaDataCommon.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Data/ActiveRecord/Vendor/TDbMetaDataCommon.php')
-rw-r--r--framework/Data/ActiveRecord/Vendor/TDbMetaDataCommon.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/framework/Data/ActiveRecord/Vendor/TDbMetaDataCommon.php b/framework/Data/ActiveRecord/Vendor/TDbMetaDataCommon.php
index 74c97689..fffdb6fb 100644
--- a/framework/Data/ActiveRecord/Vendor/TDbMetaDataCommon.php
+++ b/framework/Data/ActiveRecord/Vendor/TDbMetaDataCommon.php
@@ -161,9 +161,9 @@ abstract class TDbMetaDataCommon extends TDbMetaData
{
$conn->setActive(true);
$numKeys = count($this->getPrimaryKeys());
- if($numKeys===0)
- throw new TActiveRecordException('ar_no_primary_key_found',$this->getTableName());
$table = $this->getTableName();
+ if($numKeys===0)
+ throw new TActiveRecordException('ar_no_primary_key_found',$table);
if($numKeys===1)
$criteria = $this->getDeleteInPkCriteria($conn,$keys);
else
@@ -173,6 +173,21 @@ abstract class TDbMetaDataCommon extends TDbMetaData
$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 = $criteria!==null?$this->getSqlFromCriteria($conn,$criteria) : '';
+ $table = $this->getTableName();
+ $sql = "DELETE FROM {$table} {$conditions}";
+ return $this->createCriteriaBindedCommand($conn,$sql, $criteria);
+ }
}
?> \ No newline at end of file