本文整理汇总了PHP中blogPostModel::getTableId方法的典型用法代码示例。如果您正苦于以下问题:PHP blogPostModel::getTableId方法的具体用法?PHP blogPostModel::getTableId怎么用?PHP blogPostModel::getTableId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blogPostModel
的用法示例。
在下文中一共展示了blogPostModel::getTableId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCount
public function getCount($blog_id, $post_id = null, $datetime = null, $expire = null, $post_contact_id = null, $status = self::STATUS_PUBLISHED)
{
$where = array();
$join = array();
if ($datetime) {
$where[] = "{$this->table}.datetime > '{$this->escape($datetime)}'";
if ($contact_id = wa()->getUser()->getId()) {
$where[] = "{$this->table}.contact_id != " . intval($contact_id);
}
}
if ($post_contact_id = max(0, intval($post_contact_id))) {
$post_model = new blogPostModel();
$post_table = $post_model->getTableName();
$post_table_id = $post_model->getTableId();
$join[] = " INNER JOIN {$post_table} ON {$post_table}.{$post_table_id} = {$this->table}.post_id";
$where[] = "{$post_table}.contact_id = {$post_contact_id}";
}
if ($status) {
$where[] = $this->getWhereByField('status', $status, true);
}
if ($post_id) {
$where[] = $this->getWhereByField('post_id', $post_id, true);
}
if ($blog_id !== null) {
$where[] = $this->getWhereByField('blog_id', $blog_id, true);
}
if ($datetime) {
$count_by_post = $post_id && is_array($post_id);
if ($count_by_post) {
$count = array_fill_keys($post_id, 0);
} else {
$count = 0;
}
$sql = "SELECT {$this->table}.{$this->id} AS {$this->id}, post_id FROM {$this->table} " . implode('', $join) . " WHERE (" . implode(') AND (', $where) . ")";
if ($comments = $this->query($sql)->fetchAll($this->id, true)) {
$blog_activity = blogActivity::getInstance();
foreach ($comments as $id => $comment_post_id) {
if ($blog_activity->isNew("c.{$comment_post_id}", $id, $expire)) {
if ($count_by_post) {
++$count[$comment_post_id];
} else {
++$count;
}
}
}
$viewed_comments = array();
}
} elseif ($post_id && is_array($post_id)) {
$sql = "SELECT post_id, COUNT(*) FROM {$this->table} " . implode('', $join) . " WHERE (" . implode(') AND (', $where) . ") GROUP BY post_id";
$count = $this->query($sql)->fetchAll('post_id', true);
} else {
$sql = "SELECT COUNT(*) FROM {$this->table} " . implode('', $join) . " WHERE (" . implode(') AND (', $where) . ")";
$count = $this->query($sql)->fetchField();
}
return $count;
}