本文整理汇总了PHP中D函数的典型用法代码示例。如果您正苦于以下问题:PHP D函数的具体用法?PHP D怎么用?PHP D使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了D函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* [index 管理员列表]
* @return [type] [description]
*/
public function index()
{
if (IS_AJAX) {
$draw = I('draw', 1, 'intval');
//排序设置
$mycolumns = I('mycolumns', '');
$myorder = I('order', '');
if (empty($myorder) || empty($mycolumns)) {
$order = 'id desc';
} else {
foreach ($myorder as $key => $v) {
$order .= $mycolumns[$v['column']] . ' ' . $v['dir'] . ' ,';
}
$order = rtrim($order, ',');
}
$db = D('UsersView');
$lists = $db->where(true)->order($order)->select();
foreach ($lists as $key => $v) {
$lists[$key]['loginTime'] = $v['loginTime'] ? date('Y/m/d H:i:s', $v['loginTime']) : '';
$lists[$key]['loginIp'] = $v['loginIp'] ? long2ip($v['loginIp']) : '';
if ($v['status']) {
$lists[$key]['status'] = '正常';
} else {
$lists[$key]['status'] = '禁用';
}
}
$result['draw'] = $draw;
$result['recordsTotal'] = $db->where(true)->count();
$result['recordsFiltered'] = $result['recordsTotal'];
$result['data'] = $lists;
$this->ajaxReturn($result);
} else {
$this->display();
}
}
示例2: update
public function update()
{
$name = $this->getActionName();
$model = D($name);
$tablename = $_POST['tablename'];
foreach ($tablename as $key => $val) {
$data = array();
$data['one'] = $_POST['one'][$val];
$data['two'] = $_POST['two'][$val];
$data['three'] = $_POST['three'][$val];
$data['four'] = $_POST['four'][$val];
$data['five'] = $_POST['five'][$val];
$data['six'] = $_POST['six'][$val];
$data['seven'] = $_POST['seven'][$val];
$data['eight'] = $_POST['eight'][$val];
$data['nine'] = $_POST['nine'][$val];
$data['ten'] = $_POST['ten'][$val];
$data['eleven'] = $_POST['eleven'][$val];
$data['twelve'] = $_POST['twelve'][$val];
$data['thirteen'] = $_POST['thirteen'][$val];
$where = array();
$where['tablename'] = $val;
$result = $model->where($where)->save($data);
if (!$result) {
$this->error("编码方案修改失败");
}
}
$this->success("编码方案修改成功");
}
示例3: step3
public function step3()
{
if (IS_POST) {
if ($_POST['if2011'] != '是') {
$this->error("您已放弃报名", addons_url('Join2011://Join2011/index'));
}
//print_array($_POST);
$Stu = D('Stu');
$Bmb = D('Bmb');
$data['ksh'] = $_SESSION['ksh'];
$data['score'] = $_POST['score'];
$data['jsscore'] = $_POST['jsscore'];
$data['phone'] = $_POST['phone'];
if ($Stu->where(array('ksh' => $_SESSION['ksh']))->find()) {
} else {
$this->error("您不在初选名单", addons_url('Join2011://Join2011/index'));
}
if ($Bmb->where(array('ksh' => $_SESSION['ksh']))->find()) {
$this->error("您已经报名", addons_url('Join2011://Join2011/index'));
}
if ($Bmb->data($data)->add()) {
session('ksh', '');
$this->success('报名成功', U('Home/Index/index'));
} else {
$this->error("报名失败,请重新报名", addons_url('Join2011://Join2011/index'));
}
} else {
$this->error("您不可以直接访问这个页面", addons_url('Join2011://Join2011/index'));
}
}
示例4: login
/**
* 用户登录认证
* @param string $username 用户名
* @param string $password 用户密码
* @param integer $type 用户名类型 (1-用户名,2-邮箱,3-手机,4-UID)
* @return integer 登录成功-用户ID,登录失败-错误编号
*/
public function login($username, $password, $type = 1)
{
if (file_exists('./api/uc_login.lock')) {
include_once './api/uc_client/client.php';
if (strtolower(UC_CHARSET) == 'gbk') {
$username = iconv('UTF-8', 'GBK', $username);
}
$uc_user = uc_user_login($username, $password, 0);
if ($uc_user[0] == -2) {
return '密码错误';
} elseif ($uc_user[0] == -1) {
return '用户不存在,或者被删除';
} elseif ($uc_user[0] > 0) {
if (strtolower(UC_CHARSET) == 'gbk') {
$uc_user[1] = iconv('GBK', 'UTF-8', $uc_user[1]);
}
D('member')->where(array('uid' => $uc_user[0]))->setField('nickname', $uc_user[1]);
D('ucenter_member')->where(array('id' => $uc_user[0]))->setField('username', $uc_user[1]);
return $uc_user[0];
}
} else {
if (UC_SYNC && $username != get_username(1)) {
return $this->ucLogin($username, $password);
}
return $this->model->login($username, $password, $type);
}
}
示例5: textSkip
public function textSkip($msg)
{
$o = D('MatchKeyword');
$target = $o->matchKeyword($msg['keyword']);
$o = D("{$target}");
return $o->main($msg);
}
示例6: delete
/**
* 删除
*/
public function delete()
{
$db = D("Tags");
if (IS_POST) {
$tagid = $_POST['tagid'];
if (is_array($tagid)) {
foreach ($tagid as $tid) {
$r = $db->where(array("tagid" => $tid))->find();
if ($r) {
$db->where(array("tagid" => $tid))->delete();
M("Tags_content")->where(array("tag" => $r['tag']))->delete();
}
}
$this->success("删除成功!");
} else {
$this->error("参数错误!");
}
} else {
$tagid = (int) $this->_get('tagid');
if (!$tagid) {
$this->error("缺少参数!");
}
$r = $db->where(array("tagid" => $tagid))->find();
if (!$r) {
$this->error("该TAG不存在!");
}
$status = $db->where(array("tagid" => $tagid))->delete();
if ($status) {
M("Tags_content")->where(array("tag" => $r['tag']))->delete();
$this->success("删除成功!");
} else {
$this->error("删除失败!");
}
}
}
示例7: upload
public function upload()
{
session('upload_error', null);
/* 上传配置 */
$setting = C('EDITOR_UPLOAD');
$setting['callback'] = array($this, 'isFile');
/* 调用文件上传组件上传文件 */
$this->uploader = new Upload($setting, C('PICTURE_UPLOAD_DRIVER'));
$info = $this->uploader->upload($_FILES);
if ($info) {
$dao = D('Home/Picture');
foreach ($info as &$file) {
$file['rootpath'] = __ROOT__ . ltrim($setting['rootPath'], ".");
/* 已经存在文件记录 */
if (isset($file['id']) && is_numeric($file['id'])) {
$file['path'] = __ROOT__ . ltrim($file['path'], ".");
continue;
}
/* 记录文件信息 */
$file['path'] = __ROOT__ . ltrim($setting['rootPath'], ".") . $file['savepath'] . $file['savename'];
$file['status'] = 1;
$file['create_time'] = NOW_TIME;
if ($dao->create($file) && ($id = $dao->add())) {
$file['id'] = $id;
}
}
}
session('upload_error', $this->uploader->getError());
return $info;
}
示例8: index
public function index()
{
//列表过滤器,生成查询Map对象
$map = $this->_search();
$map['_string'] = " (is_investor=1 or is_investor=2) and investor_status!=1 ";
//追加默认参数
if ($this->get("default_map")) {
$map = array_merge($map, $this->get("default_map"));
}
if (trim($_REQUEST['user_name']) != '') {
$map[DB_PREFIX . 'user.user_name'] = array('like', '%' . trim($_REQUEST['user_name']) . '%');
}
if (trim($_REQUEST['email']) != '') {
$map[DB_PREFIX . 'user.email'] = array('like', '%' . trim($_REQUEST['email']) . '%');
}
if (method_exists($this, '_filter')) {
$this->_filter($map);
}
$name = $this->getActionName();
$model = D('User');
if (!empty($model)) {
$this->_list($model, $map);
}
$this->display();
return;
}
示例9: edit
public function edit($single_id = null)
{
$model = D('Single');
if (IS_POST) {
if ($model->create()) {
$result = $model->save();
if ($result > 0) {
$this->success(L('_UPDATE_SUCCESS_'), U('Single/index'));
} else {
$this->error(L('_UNKNOWN_ERROR_'));
}
} else {
$this->error($model->geterror());
}
} else {
if (empty($single_id)) {
$this->error(L('_ID_NOT_NULL_'));
}
$data = M('Single')->where("single_id={$single_id}")->find();
//$field=Api('Model/SingleModel');
$field = get_model_attr('single');
$this->meta_title = '编辑单页';
$this->assign('fieldarr', $field);
$this->assign('data', $data);
$this->display();
}
}
示例10: edit
/**
* 编辑配置
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function edit($id = 0)
{
if (IS_POST) {
$Config = D('Config');
$data = $Config->create();
if ($data) {
if ($Config->save()) {
S('DB_CONFIG_DATA', null);
//记录行为
action_log('update_config', 'config', $data['id'], UID);
$this->success('更新成功', Cookie('__forward__'));
} else {
$this->error('更新失败');
}
} else {
$this->error($Config->getError());
}
} else {
$info = array();
/* 获取数据 */
$info = M('Config')->field(true)->find($id);
if (false === $info) {
$this->error('获取配置信息错误');
}
$this->assign('info', $info);
$this->meta_title = '编辑配置';
$this->display();
}
}
示例11: get_run_link
public function get_run_link($id)
{
static $des;
$des = empty($des) ? new \Common\ORG\DES(C('API_DATA_CRYPT_KEY')) : $des;
$item = $this->find($id);
$item_data = $this->get_item_data($id, true);
$service_db = D('Service');
$service = $service_db->find($item['sid']);
$item_data_field = array_keys($item_data);
foreach ($item_data_field as $key => $var) {
$item_data_field[$key] = '{' . $var . '}';
}
$item_data_value = array_values($item_data);
$service_db = D('Service');
$service = $service_db->find($item['sid']);
$environment_db = D('Environment');
$eid = $environment_db->get_current_environment();
$link = [];
$link_tpl = '[protocol]://[type]/[path](des)/[parameter](des)/[attach](des)/';
$replace['[protocol]'] = C('API_PROTOCOL');
$replace['[type]'] = $service['protocol'];
$replace['[path](des)'] = '';
$replace['[parameter](des)'] = '';
$replace['[attach](des)'] = '';
$soft = D('Soft')->get_soft($item['sid'], $eid);
foreach ($soft as $var) {
$replace['[parameter](des)'] = $des->encrypt(str_replace($item_data_field, $item_data_value, $var['tpl']));
$replace['[path](des)'] = $des->encrypt($var['path']);
$replace['[attach](des)'] = $des->encrypt('pathid-' . $var['pathid'] . ',item-' . $item['id'] . ',user-' . session("admin_username"));
$link[] = array('name' => $var['name'], 'link' => str_replace(array_keys($replace), array_values($replace), $link_tpl));
}
return $link;
}
示例12: pubs
public function pubs()
{
$Pubs = D('pub');
$pub = $Pubs->where('id=' . $_GET['pid'] . ' and state=1')->find();
$this->assign('pub', $pub);
$this->display();
}
示例13: index
public function index()
{
$id = intval($_GET['id']);
$article = sp_sql_post($id, '');
$termid = $article['term_id'];
$term_obj = D("Terms");
$term = $term_obj->where("term_id='{$termid}'")->find();
$article_id = $article['object_id'];
$should_change_post_hits = sp_check_user_action("posts{$article_id}", 1, true);
if ($should_change_post_hits) {
$posts_model = M("Posts");
$posts_model->save(array("id" => $article_id, "post_hits" => array("exp", "post_hits+1")));
}
$smeta = json_decode($article['smeta'], true);
$content_data = sp_content_page($article['post_content']);
$article['post_content'] = $content_data['content'];
$this->assign("page", $content_data['page']);
$this->assign($article);
$this->assign("smeta", $smeta);
$this->assign("term", $term);
$this->assign("article_id", $article_id);
$tplname = $term["one_tpl"];
$tplname = sp_get_apphome_tpl($tplname, "article");
$this->display(":{$tplname}");
}
示例14: run
/**
* 行为扩展的执行入口必须是run
* @author jry <598821125@qq.com>
*/
public function run(&$content)
{
//安装模式下直接返回
if (defined('BIND_MODULE') && BIND_MODULE === 'Install') {
return;
}
$data = S('hooks');
if (!$data) {
$hooks = D('AddonHook')->getField('name,addons');
foreach ($hooks as $key => $value) {
if ($value) {
$map['status'] = 1;
$names = explode(',', $value);
$map['name'] = array('IN', $names);
$data = D('Addon')->where($map)->getField('id,name');
if ($data) {
$addons = array_intersect($names, $data);
Hook::add($key, array_map('get_addon_class', $addons));
}
}
}
S('hooks', Hook::get());
} else {
Hook::import($data, false);
}
}
示例15: index
/**
* Member overview
*/
public function index()
{
$keyword = isset($_GET['keyword']) ? trim($_GET['keyword']) : '';
if ($this->isAjax()) {
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$pageSize = isset($_GET['pagesize']) ? $_GET['pagesize'] : 20;
$order = isset($_GET['sortname']) ? $_GET['sortname'] : 'id';
$sort = isset($_GET['sortorder']) ? $_GET['sortorder'] : 'ASC';
$member = D('Member');
$total = $member->getMemberCount($keyword);
if ($total) {
$rows = $member->getMemberList($page, $pageSize, $order, $sort, $keyword);
foreach ($rows as &$v) {
$v['register_time'] = date("Y-m-d H:i:s", $v['register_time']);
$v['last_time'] = $v['last_time'] ? date("Y-m-d H:i:s", $v['last_time']) : $v['last_time'];
$v['upgrade_time'] = $v['upgrade_time'] ? date("Y-m-d H:i:s", $v['upgrade_time']) : $v['upgrade_time'];
}
} else {
$rows = null;
}
$this->ajaxReturn(array('Rows' => $rows, 'Total' => $total));
} else {
$this->assign('keyword', $keyword);
$this->display();
}
}