本文整理汇总了PHP中CActiveRecord::deleteByPk方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveRecord::deleteByPk方法的具体用法?PHP CActiveRecord::deleteByPk怎么用?PHP CActiveRecord::deleteByPk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveRecord
的用法示例。
在下文中一共展示了CActiveRecord::deleteByPk方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteByPk
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);
}
示例2: deleteByPk
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);
}
示例3: deleteByPk
/**
*
* @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);
}