Example #1
0
 public function deleteByPk($pk, $condition = '', $params = array())
 {
     foreach ($this->relations() as $key => $relation) {
         if ($relation[0] == self::HAS_MANY) {
             $className = $relation[1];
             $classObj = new $className();
             foreach ($classObj->model()->relations() as $keyRelation => $otherRelation) {
                 if ($otherRelation[1] == get_class($this)) {
                     if ($otherRelation[0] == self::BELONGS_TO && $otherRelation[2] == $relation[2]) {
                         foreach ($this->getRelated($key) as $obj) {
                             $obj->delete();
                         }
                     }
                     break;
                 }
             }
         }
     }
     return parent::deleteByPk($pk, $condition, $params);
 }
Example #2
0
 public function deleteByPk($pk, $condition = "", $params = array())
 {
     if ($this->getIsAllowCache()) {
         $ids = is_array($pk) ? $pk : explode(",", $pk);
         foreach ($ids as $id) {
             if (!empty($id)) {
                 CacheUtil::rm($this->getCacheKey($id));
             }
         }
     }
     return parent::deleteByPk($pk, $condition, $params);
 }
 /**
  *
  * @param mixed $pk
  * @param string $condition
  * @param array $params
  * @return boolean 
  */
 public function deleteByPk($pk, $condition = '', $params = array())
 {
     if (CStubActiveRecord::isUnittests()) {
         return CallFactory::call($this, 'deleteByPk');
     }
     return parent::deleteByPk($pk, $condition, $params);
 }