Esempio n. 1
0
 /**
  * Get count of category items
  *
  * @return int
  */
 public function getCount()
 {
     $sql = Table\CategoryItems::sql();
     $sql->select(['total_count' => 'COUNT(*)'])->join(DB_PREFIX . 'content', [DB_PREFIX . 'category_items.content_id' => DB_PREFIX . 'content.id'])->join(DB_PREFIX . 'media', [DB_PREFIX . 'category_items.media_id' => DB_PREFIX . 'media.id'])->join(DB_PREFIX . 'media_libraries', [DB_PREFIX . 'media_libraries.id' => DB_PREFIX . 'media.library_id'])->where('category_id = :category_id')->where('media_id IS NOT NULL');
     $s = (string) $sql . ' OR ((' . $sql->quoteId('media_id') . ' IS NULL) AND (' . $sql->quoteId('publish') . ' <= NOW()) AND ((' . $sql->quoteId('expire') . ' IS NULL) OR (' . $sql->quoteId('expire') . ' > NOW())) AND (' . $sql->quoteId('status') . ' = 1))';
     return Table\CategoryItems::execute($s, ['category_id' => $this->id])->total_count;
 }