foto.class.php 1.09 KB
<?php
Class Foto{
 private $db;
 private $lang;
 
 function __construct($lang){
  $this->db = sdb::getInstance();
  $this->lang = $lang;
 }
 
 public function getRubrics(){
  return $this->db->getAll("select * from foto_rubrics order by sort",array(),DB_FETCHMODE_ASSOC);
 } 
 
 public function getRubric($id){
  return $this->db->getRow("select * from foto_rubrics where id=?",array($id),DB_FETCHMODE_ASSOC);
 }  

 public function getGallery($rubric_id = 0){
  $search = array();
  if($rubric_id>0)$search[] = sprintf("rubric_id='%d'",$rubric_id);
  $sql = "select * from foto_gallery where 1=1 ";
  if(count($search))$sql .= "AND " . implode(" AND ",$search)." ";
  $sql .= "order by id desc";
  //print $sql;
  $pagerOptions = Array(
    'mode' => 'Sliding',
    'delta' => 6,
    'perPage' => 10,
    'spacesBeforeSeparator' => 1,
    'spacesAfterSeparator' => 1
  );
  return Pager_Wrapper_DB($this->db, $sql, $pagerOptions, false, DB_FETCHMODE_ASSOC, array());
 }
 
 public function getGalleryOne($id){
  return $this->db->getRow("select * from foto_gallery where id=?",array($id),DB_FETCHMODE_ASSOC);
 } 

}
?>