本文整理汇总了PHP中get_model_attribute函数的典型用法代码示例。如果您正苦于以下问题:PHP get_model_attribute函数的具体用法?PHP get_model_attribute怎么用?PHP get_model_attribute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_model_attribute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public function add()
{
$model = $this->model;
$Model = D(parse_name(get_table_name($model['id']), 1));
if (IS_POST) {
// 获取模型的字段信息
$Model = $this->checkAttr($Model, $model['id']);
if ($Model->create() && ($id = $Model->add())) {
$this->_saveKeyword($model, $id, 'custom_reply_news');
$this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
} else {
$this->error($Model->getError());
}
} else {
$fields = get_model_attribute($model['id']);
$extra = $this->getCateData();
if (!empty($extra)) {
foreach ($fields[1] as &$vo) {
if ($vo['name'] == 'cate_id') {
$vo['extra'] .= "\r\n" . $extra;
}
}
}
$this->assign('fields', $fields);
$this->meta_title = '新增' . $model['title'];
$this->display();
}
}
示例2: edit
public function edit($id = 0)
{
$model = $this->getModel($this->model);
$id || ($id = I('id'));
if (IS_POST) {
$_POST['module'] = _ADDONS;
$Model = D(parse_name(get_table_name($model['id']), 1));
// 获取模型的字段信息
$Model = $this->checkAttr($Model, $model['id']);
if ($Model->create() && $Model->save()) {
$this->_saveKeyword($model, $id);
$this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
} else {
$this->error($Model->getError());
}
} else {
$fields = get_model_attribute($model['id']);
// 获取数据
$data = M(get_table_name($model['id']))->find($id);
$data || $this->error('数据不存在!');
$this->assign('fields', $fields);
$this->assign('data', $data);
$this->meta_title = '编辑' . $model['title'];
$this->display();
}
}
示例3: edit
function edit()
{
$id = $this->shop_id;
$model = $this->getModel();
if (IS_POST) {
// $_POST ['update_time'] = NOW_TIME;
$Model = D(parse_name(get_table_name($model['id']), 1));
if ($Model->create() && $Model->save()) {
$this->_saveKeyword($model, $id);
}
// 清空缓存
method_exists($Model, 'clear') && $Model->clear($id, 'edit');
$this->success('保存' . $model['title'] . '成功!');
} else {
$fields = get_model_attribute($model['id']);
// 获取数据
$data = D('Shop')->getInfo($id, true);
$data || $this->error('数据不存在!');
$token = get_token();
if (isset($data['token']) && $token != $data['token'] && defined('ADDON_PUBLIC_PATH')) {
$this->error('非法访问!');
}
$this->assign('fields', $fields);
$this->assign('data', $data);
$this->display();
}
}
示例4: edit
public function edit($id = 0)
{
$model = $this->getModel('credit_config');
$id || ($id = I('id'));
// 获取数据
$data = M(get_table_name($model['id']))->find($id);
$data || $this->error('数据不存在!');
if (IS_POST) {
$act = 'save';
if ($data['token'] == 0) {
$_POST['token'] = get_token();
unset($_POST['id']);
$act = 'add';
}
$Model = D(parse_name(get_table_name($model['id']), 1));
// 获取模型的字段信息
$Model = $this->checkAttr($Model, $model['id']);
if ($Model->create() && $Model->{$act}()) {
// dump($Model->getLastSql());
$this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
} else {
// dump($Model->getLastSql());
$this->error($Model->getError());
}
} else {
$fields = get_model_attribute($model['id']);
$this->assign('fields', $fields);
$this->assign('data', $data);
$this->meta_title = '编辑' . $model['title'];
$this->display('Addons/edit');
}
}
示例5: edit
function edit()
{
$model = $this->getModel('business_card');
$map['uid'] = $uid = $this->mid;
$act = 'edit';
// $map['uid']=11857;
$data = M('business_card')->where($map)->find();
// $id = I ( 'id' );
// 获取数据
// $data = M ( get_table_name ( $model ['id'] ) )->find ( $id );
$data || ($act = 'add');
// $token = get_token ();
// if (isset ( $data ['token'] ) && $token != $data ['token'] && defined ( 'ADDON_PUBLIC_PATH' )) {
// $this->error ( '非法访问!' );
// }
if (IS_POST) {
$_POST['uid'] = $this->mid;
$_POST['token'] = get_token();
$Model = D(parse_name(get_table_name($model['id']), 1));
// 获取模型的字段信息
$Model = $this->checkAttr($Model, $model['id']);
if ($act == 'edit') {
if ($Model->create() && $Model->save()) {
// 清空缓存
method_exists($Model, 'clear');
// $url= '<script language=javascript>history.go(-1);</script>';
$this->success('保存' . $model['title'] . '成功!');
} else {
$this->error($Model->getError());
}
} else {
if ($Model->create() && ($id = $Model->add())) {
// 清空缓存
method_exists($Model, 'clear') && $Model->clear($id, 'add');
$this->success('添加' . $model['title'] . '成功!');
} else {
$this->error($Model->getError());
}
}
} else {
$fields = get_model_attribute($model['id']);
$this->assign('fields', $fields);
$this->assign('data', $data);
$this->display();
}
}
示例6: form
function form()
{
if (!is_login()) {
Cookie('__forward__', $_SERVER['REQUEST_URI']);
$this->error('您还没有登录,请先登录!', U('User/login'));
}
$model = M('Model')->find(I('get.model'));
$this->assign('model', $model);
$id = I('id', 0);
$this->right_data($model);
if (IS_POST) {
$Model = D(parse_name(get_table_name($model['id']), 1));
// 获取模型的字段信息
$Model = $this->checkAttr($Model, $model['id']);
$res = $Model->create();
if ($id) {
$res = $Model->save();
} else {
$res = $Model->add();
}
if ($res) {
$url = U('index');
if ($model['name'] == 'store') {
$url = U('store');
}
$this->success('保存成功!', $url);
} else {
$this->error($Model->getError());
}
} else {
$fields = get_model_attribute($model['id']);
$this->assign('fields', $fields);
// 获取数据
if ($id) {
$data = M(get_table_name($model['id']))->find($id);
$data || $this->error('数据不存在!');
$this->assign('data', $data);
}
$this->meta_title = '编辑' . $model['title'];
$this->display();
}
}
示例7: add
function add()
{
$model = $this->getModel();
if (IS_POST) {
$Model = D(parse_name(get_table_name($model['id']), 1));
// 获取模型的字段信息
$Model = $this->checkAttr($Model, $model['id']);
if ($Model->create() && ($id = $Model->add())) {
$this->_saveKeyword($model, $id);
$this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
} else {
$this->error($Model->getError());
}
} else {
$fields = get_model_attribute($model['id']);
$this->assign('fields', $fields);
$this->meta_title = '新增' . $model['title'];
$this->_deal_data();
$this->display();
}
}
示例8: add
public function add()
{
if (IS_POST) {
$Model = D(parse_name(get_table_name($this->model['id']), 1));
// 获取模型的字段信息
$Model = $this->checkAttr($Model, $this->model['id']);
if ($Model->create() && ($id = $Model->add())) {
$param['test_id'] = $this->test_id;
$param['model'] = $this->model['id'];
$url = U('lists', $param);
$this->success('添加' . $this->model['title'] . '成功!', $url);
} else {
$this->error($Model->getError());
}
exit;
}
$this->_tip();
$fields = get_model_attribute($this->model['id']);
$this->assign('fields', $fields);
$this->meta_title = '新增' . $this->model['title'];
$this->display();
}
示例9: add
public function add()
{
$model = $this->getModel('Message');
if (IS_POST) {
if (!C('SEND_GROUP_MSG')) {
$this->error('抱歉,您的公众号没有群发消息的权限');
}
$send_type = I('send_type', 0, 'intval');
$group_id = I('group_id', 0, 'intval');
$send_openids = I('send_openids');
if ($send_type == 0) {
$_POST['msg_id'] = $this->_send_by_group($group_id);
} else {
$_POST['msg_id'] = $this->_send_by_openid($send_openids);
}
$Model = D(parse_name(get_table_name($model['id']), 1));
// 获取模型的字段信息
$Model = $this->checkAttr($Model, $model['id']);
if ($Model->create() && ($id = $Model->add())) {
$this->_saveKeyword($model, $id);
// 清空缓存
method_exists($Model, 'clear') && $Model->clear($id, 'edit');
$this->success('添加' . $model['title'] . '成功!', U('add'));
} else {
$this->error($Model->getError());
}
} else {
$fields = get_model_attribute($model['id'], $model['field_sort']);
$this->assign('fields', $fields);
$this->meta_title = '新增' . $model['title'];
!C('SEND_GROUP_MSG') && $this->assign('normal_tips', '温馨提示:目前微信仅开放认证公众号的群发消息权限,未认证公众号无法使用此功能');
$map['token'] = get_token();
$map['manager_id'] = $this->mid;
$map['is_del'] = 0;
$group_list = M('auth_group')->where($map)->select();
$this->assign('group_list', $group_list);
$this->display();
}
}
示例10: add
public function add()
{
is_array($model) || ($model = $this->getModel($model));
if (IS_POST) {
// $_POST ['token'] = get_token ();
$Model = D(parse_name(get_table_name($model['id']), 1));
// 获取模型的字段信息
$Model = $this->checkAttr($Model, $model['id']);
if ($Model->create() && ($id = $Model->add())) {
$this->_saveKeyword($model, $id);
$this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
} else {
$this->error($Model->getError());
}
} else {
$fields = get_model_attribute($model['id']);
$this->assign('fields', $fields);
$this->meta_title = '新增' . $model['title'];
$templateFile || ($templateFile = $model['template_add'] ? $model['template_add'] : '');
$this->display($templateFile);
}
}
示例11: edit
public function edit()
{
$model = $this->model;
$id = I('id');
if (IS_POST) {
$_POST['token'] = get_token();
$Model = D(parse_name(get_table_name($model['id']), 1));
// 获取模型的字段信息
$Model = $this->checkAttr($Model, $model['id']);
if ($Model->create() && $Model->save()) {
D('Common/Keyword')->set($_POST['keyword'], _ADDONS, $id, $_POST['keyword_type'], 'custom_reply_news');
$this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
} else {
$this->error($Model->getError());
}
} else {
$fields = get_model_attribute($model['id']);
$extra = $this->getCateData();
if (!empty($extra)) {
foreach ($fields[1] as &$vo) {
if ($vo['name'] == 'cate_id') {
$vo['extra'] .= "\r\n" . $extra;
}
}
}
// 获取数据
$data = M(get_table_name($model['id']))->find($id);
$data || $this->error('数据不存在!');
$token = get_token();
if (isset($data['token']) && $token != $data['token'] && defined('ADDON_PUBLIC_PATH')) {
$this->error('非法访问!');
}
$this->assign('fields', $fields);
$this->assign('data', $data);
$this->meta_title = '编辑' . $model['title'];
$this->display();
}
}
示例12: edit
public function edit()
{
$id = I('get.id', '');
if (empty($id)) {
$this->error('参数不能为空!');
}
$model_id = 6;
// 获取详细数据
$Model = D('Record');
$data = $Model->detail($id);
// 获取当前的模型信息
$model = get_top_model($data['model_id']);
$model = $model[$model_id];
$this->assign('data', $data);
$this->assign('model_id', $data['model_id']);
$this->assign('model', $model);
//获取表单字段排序
$fields = get_model_attribute($model['id']);
$this->assign('fields', $fields);
//获取当前分类的文档类型
$this->assign('type_list', get_type_bycate($data['category_id']));
$this->meta_title = '编辑文档';
$this->display();
}
示例13: checkAttr
protected function checkAttr($Model, $model_id)
{
$fields = get_model_attribute($model_id, false);
$validate = $auto = array();
foreach ($fields as $key => $attr) {
if ($attr['is_must']) {
// 必填字段
$validate[] = array($attr['name'], 'require', $attr['title'] . '必须!');
}
// 自动验证规则
if (!empty($attr['validate_rule']) || $attr['validate_type'] == 'unique') {
$validate[] = array($attr['name'], $attr['validate_rule'], $attr['error_info'] ? $attr['error_info'] : $attr['title'] . '验证错误', 0, $attr['validate_type'], $attr['validate_time']);
}
// 自动完成规则
if (!empty($attr['auto_rule'])) {
$auto[] = array($attr['name'], $attr['auto_rule'], $attr['auto_time'], $attr['auto_type']);
} elseif ('checkbox' == $attr['type']) {
// 多选型
$auto[] = array($attr['name'], 'arr2str', 3, 'function');
} elseif ('datetime' == $attr['type']) {
// 日期型
$auto[] = array($attr['name'], 'strtotime', 3, 'function');
} elseif ('date' == $attr['type']) {
// 日期型
$auto[] = array($attr['name'], 'strtotime', 3, 'function');
}
}
return $Model->validate($validate)->auto($auto);
}
示例14: add
function add()
{
$model = $this->getModel();
if (IS_POST) {
$this->checkPostData();
$Model = D(parse_name(get_table_name($model['id']), 1));
// 获取模型的字段信息
$Model = $this->checkAttr($Model, $model['id']);
if ($Model->create() && ($id = $Model->add())) {
$this->_saveKeyword($model, $id);
// 清空缓存
method_exists($Model, 'clear') && $Model->clear($id, 'edit');
D('Scratch')->getScratchInfo($id, true);
$this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
} else {
$this->error($Model->getError());
}
} else {
$fields = get_model_attribute($model['id']);
$this->assign('fields', $fields);
$this->meta_title = '新增' . $model['title'];
$this->_deal_data();
$this->display();
}
}
示例15: add
public function add()
{
$Model = D(parse_name(get_table_name($this->model['id']), 1));
if (IS_POST) {
// 获取模型的字段信息
$Model = $this->checkAttr($Model, $this->model['id']);
if ($Model->create() && ($id = $Model->add())) {
$this->success('添加' . $this->model['title'] . '成功!', U('lists?model=' . $this->model['name']));
} else {
$this->error($Model->getError());
}
} else {
// 获取一级菜单
$map['pid'] = 0;
$map['token'] = get_token();
$list = $Model->where($map)->select();
foreach ($list as $v) {
$extra .= $v['id'] . ':' . $v['title'] . "\r\n";
}
$fields = get_model_attribute($this->model['id']);
if (!empty($extra)) {
foreach ($fields[1] as &$vo) {
if ($vo['name'] == 'pid') {
$vo['extra'] .= "\r\n" . $extra;
}
}
}
$this->assign('fields', $fields);
$this->meta_title = '新增' . $this->model['title'];
$this->display();
}
}