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.

82 lines
2.2 KiB
PHP

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
// +----------------------------------------------------------------------
// | 徐州梦创信息科技有限公司—专业的游戏运营,推广解决方案.
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.vlcms.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: kefu@vlcms.com QQ97471547
// +----------------------------------------------------------------------
namespace Admin\Model;
use Think\Model;
/**
* 文档基础模型
*/
class TotalSettlementModel extends Model{
/* 自动验证规则 */
protected $_validate = array(
);
/* 自动完成规则 */
protected $_auto = array(
);
//protected $this->$tablePrefix = 'tab_';
/**
* 构造函数
* @param string $name 模型名称
* @param string $tablePrefix 表前缀
* @param mixed $connection 数据库连接信息
*/
public function __construct($name = '', $tablePrefix = '', $connection = '') {
/* 设置默认的表前缀 */
$this->tablePrefix ='tab_';
/* 执行构造方法 */
parent::__construct($name, $tablePrefix, $connection);
}
/**
* 创建时间不写则取当前时间
* @return int 时间戳
* @author huajie <banhuajie@163.com>
*/
protected function getCreateTime(){
$create_time = I('post.create_time');
return $create_time?strtotime($create_time):NOW_TIME;
}
/**
* 生成不重复的name标识
* @author huajie <banhuajie@163.com>
*/
private function generateName(){
$str = 'abcdefghijklmnopqrstuvwxyz0123456789'; //源字符串
$min = 10;
$max = 39;
$name = false;
while (true){
$length = rand($min, $max); //生成的标识长度
$name = substr(str_shuffle(substr($str,0,26)), 0, 1); //第一个字母
$name .= substr(str_shuffle($str), 0, $length);
//检查是否已存在
$res = $this->getFieldByName($name, 'id');
if(!$res){
break;
}
}
return $name;
}
}