本文整理汇总了PHP中Model::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::add方法的具体用法?PHP Model::add怎么用?PHP Model::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model
的用法示例。
在下文中一共展示了Model::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_id
protected function get_id()
{
$tempObj = new Model('t_temp');
$res = $tempObj->lock(true)->find();
if ($res == null) {
$temp = 0;
$data['v_id'] = '1';
$tempObj->add($data);
} else {
$condition['t_id'] = $res['t_id'];
$data['v_id'] = (int) $res['v_id'] + 1;
$tempObj->where($condition)->save($data);
$temp = (int) $res['v_id'];
}
$t = (int) $temp + 1;
if ($t < 10) {
return '000' . $t;
} elseif ($t >= 0 && $t < 100) {
return '00' . $t;
} elseif ($t >= 100 && $t < 1000) {
return '0' . $t;
} elseif ($t >= 1000) {
return $t;
}
}
示例2: add
public function add($keyvalue)
{
$this->_utilRbac = $this->_getGlobalData('Util_Rbac', 'object');
$userClass = $this->_utilRbac->getUserClass();
$keyvalue['user_id'] = $userClass['_id'];
$keyvalue['time'] = CURRENT_TIME;
parent::add($keyvalue);
#------记录日志(生成msg)-------#
$logArr = array();
array_push($logArr, '增加了一条FAQ记录');
$this->_modelPlayerKindFaq = $this->_getGlobalData('Model_PlayerKindFaq', 'object');
$gameTypeName = $this->_modelPlayerKindFaq->getGameKind();
$gameTypeName = $gameTypeName[$keyvalue['game_type_id']];
array_push($logArr, "FAQ所属游戏[{$gameTypeName}]");
$lang = $this->_getGlobalData('lang');
$lang = $lang[$keyvalue['lang_id']];
array_push($logArr, "FAQ所属语言[{$lang}]");
$kindList = $this->_modelPlayerKindFaq->findById($keyvalue['kind_id']);
$kindName = $kindList['name'];
array_push($logArr, "FAQ所属类型[{$kindName}]");
array_push($logArr, "FAQ记录 [{$keyvalue['question']}]");
$msg = Tools::formatLog($logArr);
Tools::addLog($msg, true);
return true;
#------记录日志(生成msg)-------#
}
示例3: add
public function add($postArr)
{
if (empty($postArr['title'])) {
return array('status' => -1, 'msg' => '请填写标题', 'href' => 1);
}
if (empty($postArr['description'])) {
return array('status' => -1, 'msg' => '请填写描述', 'href' => 1);
}
if (empty($postArr['start_time'])) {
return array('status' => -1, 'msg' => '请选择开始时间', 'href' => 1);
}
if (empty($postArr['end_time'])) {
return array('status' => -1, 'msg' => '请选择结束时间', 'href' => 1);
}
$this->_utilRbac = $this->_getGlobalData('Util_Rbac', 'object');
$userClass = $this->_utilRbac->getUserClass();
$addArr = array();
$addArr['title'] = $postArr['title'];
$addArr['description'] = $postArr['description'];
$addArr['start_time'] = strtotime($postArr['start_time']);
$addArr['end_time'] = strtotime($postArr['end_time']);
$addArr['create_time'] = CURRENT_TIME;
$addArr['status'] = $postArr['status'];
$addArr['user_id'] = $userClass['_id'];
if (parent::add($addArr)) {
return array('status' => 1, 'msg' => false, 'href' => Tools::url('Askform', 'Askform'));
} else {
return array('status' => -2, 'msg' => '添加问卷失败', 'href' => 1);
}
}
示例4: addClicked
public function addClicked(SubmitButton $button)
{
$array = $button->getForm()->getValues();
if ($array['authorId'] == 'true') {
$array['author'] = dibi::query('SELECT authorId FROM authors ORDER BY authorId DESC LIMIT 1')->fetchSingle();
} elseif ($array['author'] == 0) {
$this->flashMessage('Je potřaba vybrat autora!', 'error');
return;
}
unset($array['authorId']);
try {
$array['url'] = Model::createUri($array['title'], $array['author']);
} catch (Exception $e) {
$this->flashMessage('U tohoto autora byla již vložena práce se stejným jménem', 'error');
return;
}
$array['added%sql'] = 'NOW()';
$array['edited%sql'] = 'NOW()';
$array = $this->fixValues($array);
$file = $array['file'];
unset($array['file']);
$id = Model::add($array, 'works');
if ($file != '') {
FileModel::add($id, $_FILES['file']);
}
$s = Environment::getSession('workform');
$s->author = $array['author'];
$s->award = $array['award'];
$s->year = $array['year'];
$s->type = $array['type'];
$this->flashMessage('Práce byla přidána.', 'info');
$this->redirect("this");
}
示例5: newTask
/**
* 新建任务
*/
public function newTask($postArr)
{
$difficulty = Tools::coerceInt($postArr['difficulty']);
$precastHour = Tools::coerceInt($postArr['precast_hour']);
if (empty($postArr['task_content'])) {
return array('status' => -1, 'msg' => '任务描述不能为空', 'href' => 2);
}
if (!$precastHour) {
return array('status' => -1, 'msg' => '预计完成时间不能为0', 'href' => 2);
}
if (!$postArr['accept_user_id']) {
return array('status' => -1, 'msg' => '请选择任务负责人', 'href' => 2);
}
$this->_utilRbac = $this->_getGlobalData('Util_Rbac', 'object');
$userClass = $this->_utilRbac->getUserClass();
$addArr = array();
$addArr['Id'] = date('Ymd', CURRENT_TIME) . Tools::getRandCode(5, 1);
$addArr['assign_user_id'] = $userClass['_id'];
$addArr['accept_user_id'] = $postArr['accept_user_id'];
$addArr['difficulty'] = $difficulty;
$addArr['precast_hour'] = $precastHour;
$addArr['assign_time'] = CURRENT_TIME;
$addArr['task_content'] = $postArr['task_content'];
if (parent::add($addArr)) {
return array('status' => 1, 'msg' => '增加任务成功', 'href' => Tools::url('ProgramTask', 'Index', array('zp' => 'Program')));
} else {
return array('status' => -2, 'msg' => '增加任务失败', 'href' => 2);
}
}
示例6: add
public function add($postArr)
{
if (empty($postArr['content'])) {
return array('href' => 2, 'msg' => '工作计划不能为空', 'status' => -1);
}
if (empty($postArr['group_id'])) {
return array('href' => 2, 'msg' => '请选择项目组', 'status' => -1);
}
$this->_utilRbac = $this->_getGlobalData('Util_Rbac', 'object');
$userClass = $this->_utilRbac->getUserClass();
$addArr = array();
$addArr['start_time'] = strtotime($postArr['start_time']);
$isAdd = $this->select("select Id from {$this->tName()} where user_id={$userClass['_id']} and start_time={$addArr['start_time']}", 1);
if ($isAdd) {
return array('href' => 2, 'msg' => '您今天已经填写过工作计划', 'status' => -1);
}
$addArr['end_time'] = strtotime($postArr['end_time']);
$addArr['content'] = $postArr['content'];
$addArr['group_id'] = $postArr['group_id'];
$addArr['user_id'] = $userClass['_id'];
if (parent::add($addArr)) {
return array('href' => Tools::url('ProgramDateWork', 'Index', array('zp' => 'Program')), 'msg' => '添加成功', 'status' => 1);
} else {
return array('href' => Tools::url('ProgramDateWork', 'Index', array('zp' => 'Program')), 'msg' => '添加失败', 'status' => -2);
}
}
示例7: add_data
public function add_data()
{
$data['pic'] = $this->_post('pic_url');
//1-监督信息 2-好人好事
$data['type'] = $this->_post('type');
$data['title'] = $this->_post('title');
$data['contents'] = $_POST['contents'];
$data['add_time'] = date('Y-m-d H:i:s');
$data['v_id'] = $this->get_volun_id();
if ($data['v_id'] == '' && $_SESSION['temp'] == 1) {
$this->error('请先提交个人信息', '__APP__/Index/personal', 3);
exit;
}
if ($data['type'] != '1' && $data['type'] != '2') {
$this->error('系统错误', '', 3);
exit;
}
$obj = new Model('t_contents');
$res = $obj->add($data);
if ($res) {
$this->success('提交成功', '__URL__/add_form?type=' . $data['type'], 3);
} else {
$this->error('提交失败', '', 3);
}
}
示例8: add
public function add($postArr)
{
if (empty($postArr['conf_name'])) {
return array('status' => -1, 'msg' => '请填定配置名称', 'href' => 1);
}
if (empty($postArr['description'])) {
return array('status' => -1, 'msg' => '请填定说明', 'href' => 1);
}
if (!count($postArr['option'])) {
return array('status' => -1, 'msg' => '至少要有一个投票选项', 'href' => 1);
}
if (!count($postArr['user'])) {
return array('status' => -1, 'msg' => '至少要有一个投票用户', 'href' => 1);
}
$addArr = array();
$addArr['conf_name'] = $postArr['conf_name'];
$addArr['description'] = $postArr['description'];
$addArr['is_open'] = $postArr['is_open'];
$addArr['content'] = serialize($postArr['option']);
$addArr['vote_user'] = serialize($postArr['user']);
if (parent::add($addArr)) {
return array('status' => 1, 'msg' => "增加 [{$postArr['conf_name']}] 配置成功", 'href' => Tools::url(CONTROL, ACTION, array('doaction' => 'conf')));
} else {
return array('status' => -1, 'msg' => '添加配置失败', 'href' => 1);
}
}
示例9: add
public function add($keyValue, $table = null)
{
if ($this->_hasValue($keyValue['game_type_id'], $keyValue['operator_id'])) {
return false;
} else {
return parent::add($keyValue, $table);
}
}
示例10: add
public function add($keyValue, $table = null)
{
if ($this->_hasValue($keyValue['value'])) {
return false;
} else {
return parent::add($keyValue);
}
}
示例11: add
public function add()
{
$where = array("price_left='{$this->R['price_left']}'", "price_right='{$this->R['price_right']}'");
if (!$this->check->checkAdd($this, $where)) {
$this->check->showError();
}
$addData = $this->getRequest()->filter($this->fields);
return parent::add($addData);
}
示例12: add
public function add()
{
//$_where = array("name='{$this->_R['name']}'");
//if (!$this->_check->addCheck($this, $_where)) $this->_check->error();
$_addData = $this->getRequest()->filter($this->_fields);
$_addData['user'] = $_COOKIE['user'];
$_addData['date'] = Tool::getDate();
return parent::add($_addData);
}
示例13: add
/** User specific random password handling */
public function add($data)
{
if (empty($data['set']['password'])) {
$data['set']['password'] = dechex(mt_rand(1000000, mt_getrandmax()));
}
/** @TODO Send email notification of password */
$data['password'] = md5($data['set']['password']);
return parent::add($data);
}
示例14: add
/**
* 添加反馈
*
* @param int $type 反馈的类型
* @param string $content 反馈的内容
* @param int $uid 反馈的UID,默认为0,兼容某些地方,可以匿名反馈
* @return bool
* @author Medz Seven <lovevipdsw@vip.qq.com>
**/
public function add($type, $content, $uid = 0)
{
/* # 验证类型 */
if (!($type = $this->selectAddType($type))) {
return flase;
}
/* # 添加数据 */
return parent::add(array('content' => $content, 'cTime' => time(), 'type' => $type, 'uid' => intval($uid)));
}
示例15: addClicked
public function addClicked(SubmitButton $button)
{
$array = $button->getForm()->getValues();
$array = $this->convertNumberToClass($array);
$array['authorUrl'] = Model::createAuthorUri($array['name'], $array['surname'], $array['class']);
Model::add($array, 'authors');
$this->flashMessage($array['name'] . " " . $array['surname'] . ' byl přidán.');
$this->redirect("this");
}