本文整理匯總了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);
}