From dd028bec3822d1d9c28c35d599d687e038c7705f Mon Sep 17 00:00:00 2001 From: wei <> Date: Thu, 4 Jan 2007 11:23:26 +0000 Subject: Add chat demo and tutorial. --- .../Data/ActiveRecord/Vendor/TDbMetaDataCommon.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'framework/Data/ActiveRecord/Vendor') 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 -- cgit v1.2.3