Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/video/models/category.php
Строк: 19
<?php
class VModel_Admin_category extends VModel
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
add_video($cat_id$video_id)
    {
          
$this->db->query("
              INSERT INTO #__video_category
              SET cat_id = "
.$cat_id.",
                  video_id = "
.$video_id
          
);
          
          if (
$this->db->affected_rows()) {
              
$this->db->query("
                  UPDATE #__video_categories
                  SET total_videos = total_videos+1
                  WHERE cat_id = "
.$cat_id."
                  LIMIT 1
              "
);
          }
    }
    
    public function 
count($params)
    {
        
$where  = ($params['where']) ? 'WHERE '.$params['where'] : '';
        
$this->db->query("
            SELECT COUNT(*) AS total_categories
            FROM #__videos_categories AS c"
.$where
        
);

        return 
$this->db->fetch_field('total_categories');
    }    

    public function 
categories($fields = array(), $params = array(), $limit 0)
    {
        
$fields = ($fields) ? $fields : array(
              
'c.cat_id''c.parent_id''c.name',
              
'c.slug''c.total_videos''c.status'
          
);
        
$where  = (isset($params['where']) && $params['where']) ? ' WHERE '.$params['where'] : '';
        
$sort   = (isset($params['sort'])) ? $params['sort'] : 'c.cat_id';
        
$order  = (isset($params['order'])) ? $params['order'] : 'DESC';
        
$limit  = ($limit != '0') ? " LIMIT ".$limit '';
          
        
$this->db->query("
            SELECT "
.implode(', '$fields)."
            FROM #__video_categories AS c"
.$where."
            ORDER BY "
.$sort.' '.$order.$limit
        
);

        return (
$this->db->affected_rows())
            ? 
$this->db->fetch_rows()
            : array();
    }
}
Онлайн: 5
Реклама