本文整理汇总了PHP中blogPostModel::getByField方法的典型用法代码示例。如果您正苦于以下问题:PHP blogPostModel::getByField方法的具体用法?PHP blogPostModel::getByField怎么用?PHP blogPostModel::getByField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blogPostModel
的用法示例。
在下文中一共展示了blogPostModel::getByField方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
$user_id = wa()->getUser()->getId();
$comment_model = new blogCommentModel();
$post_model = new blogPostModel();
$comments = $comment_model->getByField('id', $id, 'id');
$post_ids = array();
foreach ($comments as $comment) {
$post_ids[] = $comment['post_id'];
}
$post_ids = array_unique($post_ids);
$posts = $post_model->getByField('id', $post_ids, 'id');
$available = array();
foreach ($comments as $comment) {
try {
$rights = blogHelper::checkRights($comment['blog_id'], $user_id, blogRightConfig::RIGHT_READ_WRITE);
} catch (Exception $e) {
continue;
}
if ($rights == blogRightConfig::RIGHT_READ_WRITE && $user_id != $posts[$comment['post_id']]['contact_id']) {
continue;
}
if ($comment['status'] == blogCommentModel::STATUS_DELETED) {
continue;
}
$available[] = $comment['id'];
}
$comment_model->updateById($available, array('status' => blogCommentModel::STATUS_DELETED));
$this->response = true;
}
示例2: insertPost
protected function insertPost($post)
{
static $post_model;
if (!$post_model) {
$post_model = new blogPostModel();
}
if (empty($post['contact_id'])) {
$post['contact_id'] = $this->settings['contact'];
}
$method = __METHOD__;
$this->log(var_export(compact('method', 'post'), true));
$post['blog_id'] = $this->settings['blog'];
$post['blog_status'] = $this->settings['blog_status'];
$post['text'] = $this->userReplace($post['text']);
$post_model->ping();
switch ($field = $this->settings['mode']) {
case 'title':
if ($p = $post_model->getByField(array($field => $post[$field], 'blog_id' => $post['blog_id']))) {
$this->log("Post with timestamp [{$post['timestamp']}] skipped because there was a duplicate (id={$p['id']})", self::LOG_NOTICE);
$this->log("Post raw data " . var_export($post, true), self::LOG_DEBUG);
return false;
}
break;
}
if ($post['blog_status'] == blogBlogModel::STATUS_PUBLIC) {
$post['url'] = $post_model->genUniqueUrl(empty($post['url']) ? $post['title'] : $post['url']);
} elseif (!empty($post['url'])) {
$post['url'] = $post_model->genUniqueUrl($post['url']);
} else {
$post['url'] = '';
}
$post['id'] = $post_model->updateItem(null, $post);
return $post;
}