<?php
/**
 * Copy Right IJH.CC
 * Each engineer has a duty to keep the code elegant
 * $Id$
 */

if(!defined('__CORE_DIR')){
    exit("Access Denied");
}

class Mdl_Xiche_Order_photo extends Mdl_Table
{   
  
    protected $_table = 'xiche_order_photo';
    protected $_pk = 'photo_id';
    protected $_cols = 'photo_id,order_id,staff_id,before,before_time,after,after_time';


    
    public function create($data)
    {
 

    	if(!$o = $this->insert($data, true)){
    		return false;
    	}

        return $o;
    }
    
    
    
     public function insert($data)
    {


        $data['before'] = $data['before'] ? $data['before'] :  '';
        $data['after'] = $data['after'] ? $data['after'] :  '';
        $data['before_time'] = $data['before_time'] ? $data['before_time'] :  __CFG::TIME;
        $data['after_time'] = $data['after_time'] ? $data['after_time'] :  __CFG::TIME;
        if($uid = $this->db->insert($this->_table, $data, true)){
            //$this->db->Execute("INSERT INTO ".$this->table('member_fields')."(uid) VALUES('$uid')");
            return $uid;
        }
        
    }
    
    
    
  /* protected function _format_row($row)
    {
        $row['before_photos'] = explode('|', $row['before']);
        $row['after_photos'] = explode('|', $row['after']);
        return $row;
    }*/
    
    
    public function updates($photo_id,$data,$checked=false)
    {
        $data['before_time'] = $data['before_time'] ? $data['before_time'] :  __CFG::TIME;
        $data['after_time'] = $data['after_time'] ? $data['after_time'] :  __CFG::TIME;
        return $this->db->update($this->_table, $data, self::field($this->_pk, $photo_id));
    }
    
    
    
}