Skip to content

Instantly share code, notes, and snippets.

@kamaulynder
Created June 4, 2014 22:28
Show Gist options
  • Save kamaulynder/0fd6311cb39fdbce6486 to your computer and use it in GitHub Desktop.
Save kamaulynder/0fd6311cb39fdbce6486 to your computer and use it in GitHub Desktop.
/**
* Get a count of tags,posts,sets,users
*
* GET /api/stats
*
* @return void
*/
public function action_get_index_collection()
{
//Count of all tags
$tags_query = ORM::factory('Tag')
->order_by($this->_record_orderby, $this->_record_order)
->offset($this->_record_offset)
->limit($this->_record_limit);
$tags = $tags_query->find_all();
$count = $tags->count();
//Count of all posts
$posts_query = ORM::factory('Post')
->order_by($this->_record_orderby, $this->_record_order)
->offset($this->_record_offset)
->limit($this->_record_limit);
$posts = $posts_query->find_all();
$count = $posts->count();
// Respond with count
$this->_response_payload = array(
'count' => $count
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment