<?php
/**
 * Copyright (C) LJCMS All rights reserved.
 * <E-Mail：aspcms@qq.com>
 * Url http://www.liangjing.org
 *     http://www.8CMS.com
 * Update 2016.03.19
 */

class noticeOModel extends X {

        
        public function getList($items){
                    $where      = " WHERE 1=1".$items['searchsql'];
                    $start      = ($items['page']-1)*$items['pagesize'];
                    $countsql   = "SELECT COUNT(*) AS my_count FROM ".DB_PREFIXOA."notice ".$where;
                    $total      = parent::$obj->fetch_count($countsql);
                    $sql        = "SELECT * FROM ".DB_PREFIXOA."notice ".$where." ORDER BY time asc LIMIT ".$start.", ".$items['pagesize']."";
                    $array = parent::$obj->getall($sql);
                    return array($total, $array);
        }

  
        public function get_top_menu_data($id){
	        $sql = "SELECT * FROM ".DB_PREFIXOA."notice WHERE id='".$id."'";
                return parent::$obj->fetch_first($sql);
	}
 


               public function doEdit($id,$arr){
                 
                unset($arr['id']);
                unset($arr['opmode']);
                unset($arr['ajax']);           
                $result = parent::$obj->update(DB_PREFIXOA.'notice', $arr, 'id='.$id.'');
                return $result;
        }  
        public function doAdd($array) {
          
             unset($array['ajax']);
             unset($array['opmode']);
             $array['time']= time();
             $array['user_id']= $_SESSION['USER_AUTH_KEY']; 
             $array['user_name']= $_SESSION['user_name']; 
           return parent::$obj->insert(DB_PREFIXOA.'notice', $array); 
      }
      public function del($id){
        $sql = "DELETE FROM ".DB_PREFIXOA."notice WHERE id='".intval($id)."'";
        return parent::$obj->query($sql);
      }
      

        
}
?>
