<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class SrazyModel extends Repository {
    
    public function getSraz($id) {
        return $this->connection->table('srazy')
                ->where('id',$id)->fetch();
    }
    
     public function getSrazy() {
        return $this->connection->table('srazy');
    }
   
    
    public function updateSraz($id, $data) {
    $this->connection->table('srazy')
        ->where('id = ?', $id)
        ->update($data);
    }

    public function deleteSraz($id) {
        $this->connection->table('srazy')
            ->where('id = ?', $id)
            ->delete();
    }
    
    public function addSraz($data) {
    $this->connection->table('srazy')
        ->insert($data);
    }
    
     
    
    public function getGalerieBySrazId($id) {
            return $this->connection->table('srazy_galerie')
            ->where('id_srazu = ?', $id);
    }
    
    public function getFotkyByGalerieId($id) {
        return $this->connection->table('srazy_fotky')
            ->where('id_galerie = ?', $id);
    }
     
    
    public function getGalerieById($id) {
            return $this->connection->table('srazy_galerie')
            ->where('id = ?', $id)->fetch();
    }
    
    
     public function getFotkaById($id) {
            return $this->connection->table('srazy_fotky')
            ->where('id = ?', $id)->fetch();
    }
    
    
    
    public function updateFotka($id, $data) {
    $this->connection->table('srazy_fotky')
        ->where('id = ?', $id)
        ->update($data);
    }
    
  

    public function deleteFotka($id) {
        $this->connection->table('srazy_fotky')
            ->where('id = ?', $id)
            ->delete();
    }
    
    public function addFotka($data) {
     $this->connection->table('srazy_fotky')
        ->insert($data);
    //$this->id = $row->id;
    }
    
    public function addGalerie($data) {
     $this->connection->table('srazy_galerie')
        ->insert($data);
    //$this->id = $row->id;
    }
    
    public function deleteGalerie($id) {
        $this->connection->table('srazy_galerie')
            ->where('id = ?', $id)
            ->delete();
    }
    
    
    
}

