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

	function get_musteri_ad($id){
		 $this->db->select('ad');	 
		$this->db->where('id', $id);
		$query = $this->db->get('musteri')->row_array();
				
		return $query['ad'];
		
	}  
	/*
     * Get Müşteri logo alma fonksiyonu
     */

	function get_musteri_logo($id){
		 $this->db->select('logo');	 
		$this->db->where('id', $id);
		$query = $this->db->get('musteri')->row_array();
				
		return $query['logo'];
		
	} 

	  
    /*
     * Get all musteri
     */
    function get_all_musteri()
    {
		$this->db->where('aktif', 1);
        $this->db->order_by('id', 'desc');
        return $this->db->get('musteri')->result_array();
    }
        
    /*
     * function to add new musteri
     */
    function add_musteri($params)
    {
        $this->db->insert('musteri',$params);
        return $this->db->insert_id();
    }
    
    /*
     * function to update musteri
     */
    function update_musteri($id,$params)
    {
        $this->db->where('id',$id);
        return $this->db->update('musteri',$params);
    }
    
    /*
     * function to delete musteri
     */
    function delete_musteri($id)
    {
        return $this->db->delete('musteri',array('id'=>$id));
    }
}
