本文整理汇总了PHP中parse_name函数的典型用法代码示例。如果您正苦于以下问题:PHP parse_name函数的具体用法?PHP parse_name怎么用?PHP parse_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
}
示例2: edit
public function edit($model = null, $id = 0)
{
is_array($model) || ($model = $this->getModel($model));
$id || ($id = I('id'));
if (IS_POST) {
$Model = D(parse_name(get_table_name($model['id']), 1));
// 清空旧关键词
$keyword = $Model->where('id=' . $id)->getField('keyword');
$keyword = preg_split('/[\\s,;]+/', $keyword);
// 以空格tab逗号分号分割关键词
$data['addon'] = 'Extensions';
foreach ($keyword as $key) {
$data['keyword'] = trim($key);
$res = M('keyword')->where($data)->delete();
}
// 获取模型的字段信息
$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 {
parent::edit($model, $id);
}
}
示例3: add
public function add()
{
$model = $this->model;
$Model = D(parse_name(get_table_name($model['id']), 1));
$shop_id = $_POST['shop_id'] = $this->shop_id;
if (IS_POST) {
if ($_POST['imgs'] && count($_POST['imgs']) > 0) {
$_POST['imgs'] = implode(',', $_POST['imgs']);
}
// 获取模型的字段信息
$Model = $this->checkAttr($Model, $model['id']);
if ($Model->create() && ($id = $Model->add())) {
D('Common/Keyword')->set($_POST['keyword'], _ADDONS, $id, $_POST['keyword_type'], 'custom_reply_news');
$this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name'] . '&shop_id=' . $shop_id));
} else {
$this->error($Model->getError());
}
} else {
$fields = get_model_attribute($model['id']);
$extra = $this->getCateData();
if (!empty($extra)) {
foreach ($fields as &$vo) {
if ($vo['name'] == 'category_id') {
$vo['extra'] .= "\r\n" . $extra;
}
}
}
$this->assign('fields', $fields);
$this->meta_title = '新增' . $model['title'];
$this->display();
}
}
示例4: 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())) {
$this->_saveKeyword($this->model, $id);
// 清空缓存
method_exists($Model, 'clear') && $Model->clear($id, 'edit');
$param['reserve_id'] = $this->reserve_id;
$param['model'] = $this->model['id'];
$url = U('lists', $param);
$this->success('添加' . $this->model['title'] . '成功!', $url);
} else {
$this->error($Model->getError());
}
exit;
}
$normal_tips = '字段类型为单选、多选、下拉选择的参数格式第行一项,每项的值和标题用英文冒号分开。如:<br/>0:男<br/>1:女<br/>2:保密<br/>';
$normal_tips .= '字段类型为级联的参数格式有两种:
<br/>一是数据源从数据库取,如: type=db&table=common_category&module=shop_category
<br/>二是手工输入,如: type=text&data=[广西[南宁,桂林], 广东[广州, 深圳[福田区, 龙岗区, 宝安区]]]';
$this->assign('normal_tips', $normal_tips);
parent::common_add($this->model);
}
示例5: logic
/**
* 获取扩展模型对象
* @param integer $model_id 模型编号
* @return object 模型对象
*/
function logic($model_id)
{
$name = parse_name(get_document_model($model_id, 'name'), 1);
$class = is_file(MODULE_PATH . 'Logic/' . $name . 'Logic' . EXT) ? $name : 'Base';
$class = MODULE_NAME . '\\Logic\\' . $class . 'Logic';
return new $class($name);
}
示例6: display
/**
* 模板显示 调用内置的模板引擎显示方法,
* @access protected
* @param string $templateFile 指定要调用的模板文件
* @return void
*/
protected function display($template)
{
$file = T('Addons://' . parse_name($_GET['_addons'], 1) . '@./' . ucfirst($_GET['_controller']) . '/' . $_GET['_action']);
define('IS_ADDON', true);
parent::display($file);
// 重要:要避免陷入$this->display()循环
}
示例7: edit
function edit()
{
$map['id'] = $id = I('id');
$map['token'] = get_token();
$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() && $Model->save()) {
$this->_saveKeyword($model, $id);
}
// 清空缓存
method_exists($Model, 'clear') && $Model->clear($id, 'edit');
$this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
} else {
$normal_tips = "贺卡模板目前仅支持在贺卡插件目录下由制作人员添加";
$this->assign('normal_tips', $normal_tips);
$data = D('WishCard')->find($id);
$this->assign('data', $data);
$template = $this->_getTemplateInfo($data['template_cate'], $data['template']);
$this->assign('template', $template);
$this->display();
}
}
示例8: 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');
}
}
示例9: edit
public function edit()
{
is_array($model) || ($model = $this->getModel($model));
$id || ($id = I('id'));
if (IS_POST) {
$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'];
$templateFile || ($templateFile = $model['template_edit'] ? $model['template_edit'] : '');
$this->display($templateFile);
}
}
示例10: 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();
}
}
示例11: show_colums_after_connected_from_file
function show_colums_after_connected_from_file($argv)
{
$config = (include $argv[0]);
$table = $argv[1];
$argv = array(0 => $config['DB_HOST'] . ':' . $config['DB_PORT'], 1 => $config['DB_USER'], 2 => $config['DB_PWD'], 3 => $config['DB_NAME'], 4 => $config['DB_PREFIX'] . parse_name($table));
show_colums($argv);
}
示例12: 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_text');
$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();
}
}
示例13: edit
function edit()
{
$cateMap['token'] = $map['token'] = get_token();
$map['id'] = $id = I('id');
$model = $this->getModel('wish_card_content');
if (IS_POST) {
$Model = D(parse_name(get_table_name($model['id']), 1));
//读分类名称
$cate_data['id'] = $_POST['content_cate_id'];
$_POST['content_cate'] = M('WishCardContentCate')->where($cate_data)->getField('content_cate_name');
// 获取模型的字段信息
$Model = $this->checkAttr($Model, $model['id']);
if ($Model->create() && $Model->save()) {
$this->_saveKeyword($model, $id);
}
// 清空缓存
method_exists($Model, 'clear') && $Model->clear($id, 'edit');
$this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
} else {
$cate = D('WishCardContentCate')->where($cateMap)->select();
$data = D('WishCardContent')->find($id);
for ($i = 0; $i < count($cate); $i++) {
if ($cate[$i]['id'] == $data['content_cate_id']) {
$cate[$i]['checked'] = true;
}
}
$this->assign('content_cate', $cate);
$this->assign('data', $data);
//dump($cate);
$this->display(T('Addons://WishCard@WishCard/editWishContent'));
}
}
示例14: export
function export()
{
set_time_limit(0);
// 获取模型信息
$model = $this->model;
// 解析列表规则
$list_data = $this->_list_grid($model);
$grids = $list_data['list_grids'];
$fields = $list_data['fields'];
foreach ($grids as $v) {
if ($v['title'] == '操作') {
array_pop($grids);
} else {
$arr = explode('|', $v['field'][0]);
if (count($arr) > 1) {
$fun[$arr[0]] = $arr[1];
}
$ht[$arr[0]] = $v['title'];
}
}
$dataArr[0] = $ht;
// 搜索条件
$map = $this->_search_map($model, $fields);
$map['ask_id'] = $this->ask_id;
$name = parse_name(get_table_name($model['id']), true);
$data = M($name)->field(empty($fields) ? true : $fields)->where($map)->order($order)->select();
if ($data) {
$qdao = D('AskQuestion');
foreach ($data as &$vv) {
$user = get_followinfo($vv['uid']);
$vv['nickname'] = $user['nickname'];
$vv['times'] += 1;
$vv['question_id'] = $qdao->getQuestionTitle($vv['question_id'], $this->ask_id);
$vv['answer'] = implode(', ', unserialize($vv['answer']));
$vv['is_correct'] = $vv['is_correct'] == 1 ? '是' : '否';
}
foreach ($data as &$vo) {
foreach ($vo as $name => &$vv) {
if (isset($fun[$name])) {
if ($fun[$name] == 'get_name_by_status') {
$vv = get_name_by_status($vv, $name, $model['id']);
} else {
$vv = call_user_func($fun[$name], $vv);
}
}
}
foreach ($ht as $key => $val) {
$newArr[$key] = empty($vo[$key]) ? ' ' : $vo[$key];
}
$vo = $newArr;
}
$dataArr = array_merge($dataArr, $data);
}
if ($return) {
return $dataArr;
} else {
outExcel($dataArr, $map['module']);
}
}
示例15: __call
function __call($method, $params)
{
$method = parse_name($method, 0);
//函数命名风格转换,兼容驼峰法
if (function_exists($method)) {
return call_user_func_array($method, $params);
} else {
return -1;
//api函数不存在
}
}