* displayed in the catalog.
*
* TODO: filter, limit, ordering parameters
+ * @param int $category_id DB category ID
+ * @param int $offset
+ * @param int $count
* @return array a list of videos, each one being an assoc array with:
* * id, name, title, duration, thumbs_count, default_thumb, views => from DB
* * shorted_title => ellipsized title
* * TODO: user_id, user_name
* * thumbs => thumbnail images' URLs
*/
- public function get_videos_summary($category_id)
+ public function get_videos_summary($category_id, $offset, $count)
{
$this->load->helper('text');
default_thumb
FROM `videos`
WHERE category_id = ?
- ORDER BY name', // TODO summary order
- $category_id);
- $videos = $query->result_array();
+ ORDER BY name
+ LIMIT ?, ?', // TODO summary order
+ array(intval($category_id), $offset, $count));
+
+ if ($query->num_rows() > 0)
+ $videos = $query->result_array();
+ else
+ return NULL;
foreach ($videos as & $video)
{
return $videos;
}
+ public function get_videos_count($category_id)
+ {
+ $query = $this->db->query(
+ 'SELECT COUNT(*) count
+ FROM `videos`
+ WHERE category_id = ?',
+ $category_id);
+
+ if ($query->num_rows() > 0)
+ return $row = $query->row()->count;
+
+ // Error
+ return NULL;
+ }
+
/**
* Retrieves information about a video.
*