Frontend\Modules\Blog\Engine\Model::getAllComments PHP Method

getAllComments() public static method

Get all comments (at least a chunk)
public static getAllComments ( integer $limit = 10, integer $offset ) : array
$limit integer The number of items to get.
$offset integer The offset.
return array
    public static function getAllComments($limit = 10, $offset = 0)
    {
        return (array) FrontendModel::getContainer()->get('database')->getRecords('SELECT i.id, UNIX_TIMESTAMP(i.created_on) AS created_on, i.author, i.text,
             p.id AS post_id, p.title AS post_title, m.url AS post_url
             FROM blog_comments AS i
             INNER JOIN blog_posts AS p ON i.post_id = p.id AND i.language = p.language
             INNER JOIN meta AS m ON p.meta_id = m.id
             WHERE i.status = ? AND i.language = ?
             GROUP BY i.id
             ORDER BY i.created_on DESC
             LIMIT ?, ?', array('published', LANGUAGE, (int) $offset, (int) $limit));
    }

Usage Example

Example #1
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     $this->items = FrontendBlogModel::getAllComments();
 }