You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.0 KiB
PHTML
67 lines
2.0 KiB
PHTML
5 years ago
|
<?php
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | OneThink [ WE CAN DO IT JUST THINK IT ]
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Author: huajie <banhuajie@163.com>
|
||
|
// +----------------------------------------------------------------------
|
||
|
|
||
|
namespace Admin\Model;
|
||
|
use Think\Model;
|
||
|
|
||
|
/**
|
||
|
* 文档基础模型
|
||
|
*/
|
||
|
class AdvModel extends Model{
|
||
|
|
||
|
|
||
|
|
||
|
/* 自动验证规则 */
|
||
|
protected $_validate = array(
|
||
|
array('data', 'require', '广告图片不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
|
||
|
);
|
||
|
|
||
|
/* 自动完成规则 */
|
||
|
protected $_auto = array(
|
||
|
array('start_time', 'start_deal', self::MODEL_BOTH, 'callback'),
|
||
|
array('end_time', 'time_deal', self::MODEL_BOTH, 'callback'),
|
||
|
array('create_time', 'getCreateTime', self::MODEL_INSERT, 'callback'),
|
||
|
);
|
||
|
|
||
|
protected function getCreateTime(){
|
||
|
$create_time = I('post.create_time');
|
||
|
return $create_time?strtotime($create_time):NOW_TIME;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 构造函数
|
||
|
* @param string $name 模型名称
|
||
|
* @param string $tablePrefix 表前缀
|
||
|
* @param mixed $connection 数据库连接信息
|
||
|
*/
|
||
|
public function __construct($name = '', $tablePrefix = '', $connection = '') {
|
||
|
/* 设置默认的表前缀 */
|
||
|
$this->tablePrefix ='tab_';
|
||
|
/* 执行构造方法 */
|
||
|
parent::__construct($name, $tablePrefix, $connection);
|
||
|
}
|
||
|
|
||
|
public function start_deal($time){
|
||
|
if(empty($time)){
|
||
|
$time = time();
|
||
|
}else{
|
||
|
$time = strtotime($time);
|
||
|
}
|
||
|
return $time;
|
||
|
}
|
||
|
|
||
|
public function time_deal($time){
|
||
|
if(empty($time)){
|
||
|
$time = 0;
|
||
|
}else{
|
||
|
$time = strtotime($time);
|
||
|
}
|
||
|
return $time;
|
||
|
}
|
||
|
}
|