<?php
/* 
 * Generated by CRUDigniter v3.2 
 * www.crudigniter.com
 */
 
class Calisan_model extends CI_Model
{
    function __construct()
    {
        parent::__construct();
    }
    
    /*
     * Get calisan by id
     */
    function get_calisan($id)
    {
        return $this->db->get_where('calisan',array('id'=>$id))->row_array();
    }
      
	/*
     * Get calisan adını alma fonksiyonu
     */

	function get_calisan_ad($id){
		 $this->db->select('ad');	 
		$this->db->where('id', $id);
		$query = $this->db->get('calisan')->row_array();
				
		return $query['ad'];
		
	}
	/*
     * Get calisan logo alma fonksiyonu
     */

	function get_calisan_profil($id){
		 $this->db->select('profil');	 
		$this->db->where('id', $id);
		$query = $this->db->get('calisan')->row_array();
				
		return $query['profil'];
		
	}

	  
    /*
     * Get all calisan
     */
    function get_all_calisan()
    {
        $this->db->order_by('id', 'desc');
        return $this->db->get('calisan')->result_array();
    }
    /*
     * function to add new calisan
     */
    function add_calisan($params)
    {
        $this->db->insert('calisan',$params);
        return $this->db->insert_id();
    }
    
    /*
     * function to update calisan
     */
    function update_calisan($id,$params)
    {
        $this->db->where('id',$id);
        return $this->db->update('calisan',$params);
    }
    
    /*
     * function to delete calisan
     */
    function delete_calisan($id)
    {
        return $this->db->delete('calisan',array('id'=>$id));
    }
	
	function loginverikontrol($username,$password){
		 	 
		$this->db->where('kulad', $username);
		$this->db->where('sifre', $password);
		$this->db->where('aktif', 1);
		$query = $this->db->get('calisan');
				
		
		if ($query->num_rows() > 0) {
			$row = $query->row();
			return $row;
		}else {
			return 0;
		}
  }
  
	 
}
