本文整理汇总了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;
}