<?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 FotkyPsuModel extends Repository {
    
    
    
   
    public function getFotkyByPesId($id) {
            return $this->connection->table('fotky_psu')
            ->where('id_psa = ?', $id)->fetchAll();
    }
    
    public function getNahledByPesId($id) { 
       
            return $this->connection->table('fotky_psu')
            ->where('id_psa = ?' , $id)->where('maly_nahled IS NOT NULL')->where('velky_nahled IS NOT NULL')->fetch();
    }
    
     public function getFotkaById($id) {
            return $this->connection->table('fotky_psu')
            ->where('id = ?', $id)->fetch();
    }
    
    public function getMalyNahledByPesId($id) {
            return $this->connection->table('fotky_psu')
            ->where('id_psa = ? AND maly_nahled = ?', $id, 1)->fetch();
    }
    
    public function getVelkyNahledByPesId($id) {
            return $this->connection->table('fotky_psu')
            ->where('id_psa = ? AND velky_nahled = ?', $id, 1)->fetch();
    }
    
    public function updateFotka($id, $data) {
    $this->connection->table('fotky_psu')
        ->where('id = ?', $id)
        ->update($data);
    }
    
  

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

}

