本文整理匯總了PHP中blogPostModel::deleteByField方法的典型用法代碼示例。如果您正苦於以下問題:PHP blogPostModel::deleteByField方法的具體用法?PHP blogPostModel::deleteByField怎麽用?PHP blogPostModel::deleteByField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類blogPostModel
的用法示例。
在下文中一共展示了blogPostModel::deleteByField方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
public function execute()
{
if ($ids = $this->getRequest()->post('id', null, waRequest::TYPE_ARRAY_INT)) {
$post_model = new blogPostModel();
$blog_model = new blogBlogModel();
$blogs = $blog_model->getAvailable($this->getUser(), 'id');
$options = array('id' => $ids, 'blog_id' => array_keys($blogs));
$this->response['deleted'] = $post_model->deleteByField($options);
$this->logAction('post_delete', implode(',', $ids));
} else {
$this->errors[] = 'empty request';
}
}
示例2: execute
public function execute()
{
$id = $this->post('id', true);
if (!is_array($id)) {
if (strpos($id, ',') !== false) {
$id = array_map('intval', explode(',', $id));
} else {
$id = array($id);
}
}
$post_model = new blogPostModel();
$blog_model = new blogBlogModel();
$blogs = $blog_model->getAvailable(wa()->getUser(), 'id');
$post_model->deleteByField(array('id' => $id, 'blog_id' => array_keys($blogs)));
$this->response = true;
}
示例3: deleteByField
/**
* Delete records from table by primary key
*
* @param array|string $field
* @param $value
* @return bool
*/
public function deleteByField($field, $value = null)
{
$items = $this->getByField($field, $value, $this->id);
$blog_ids = array_keys($items);
/**
* @event blog_predelete
* @param array[] int $blog_ids array of blog's ID
* @return void
*/
wa()->event('blog_predelete', $blog_ids);
$res = parent::deleteByField($field, $value);
if ($res) {
$post_model = new blogPostModel();
$post_model->deleteByField('blog_id', $blog_ids);
/**
* @event blog_delete
* @param array[] int $blog_ids array of blog's ID
* @return void
*/
wa()->event('blog_delete', $blog_ids);
}
return $res;
}