ecmall 点滴记录

时间:2025-03-24 10:05:07
/* 取得列表数据 */
$model_wish =& m('wish');
$wish= $model_wish->find(array(
'conditions' => 'user_id = ' . $this->visitor->get('user_id'),//这里是查询条件
));
$this->assign('wishlist', $wish);

弹出对话框时:

<b class="ico1" ectype="dialog" dialog_title="{$lang.wish_create}" dialog_id="wish_add" dialog_width="600" uri="index.php?app=wish&act=add">弹窗</b>

dialog_id必须是当前弹窗的app_act,否则会和后台的app_act不对应,导致弹窗无法关闭。

获取用户sessionid:$this->visitor->get('user_id')      $_SESSION['user_info']['user_id']

<?php
$options = array('equal'=>'ccc');
!isset($options['equal']) && $options['equal'] = '=';
echo $options['equal']
?>

代码含义是如果options数组中定义了某个键,那么就显示这个定义的,如果没定义,或为空,那么会自动赋值=号。

会员中心添加、修改、删除代码

 function add()
{
if (!IS_POST)
{
/* 当前位置 */
/*$this->_curlocal(LANG::get('member_center'), 'index.php?app=member',
LANG::get('my_address'), 'index.php?app=my_address',
LANG::get('add_address'));*/
//$this->import_resource('mlselection.js, jquery.plugins/jquery.validate.js');
$this->assign('act', 'add');
header('Content-Type:text/html;charset=' . CHARSET);
$this->display('wish.form.html');
}
else
{
/* 心愿名称必填 */
if (!$_POST['wish_title'])
{
$this->pop_warning('wishtitle_required');
return;
} $data = array(
'user_id' => $this->visitor->get('user_id'),
'wish_title'=> $_POST['wish_title'],
'way' => $_POST['way'],
'ctime' => strtotime(date('Y-m-d H:i:s'))-date("Z"),
'isdefault' => $_POST['default'],
'namee' => $_POST['names'],
'email' => $_POST['email'],
'sr' => $_POST['sr'],
'mycont' => $_POST['mycont'],
'myset' => $_POST['myset'],
);
$model_wish =& m('wish');
if (!($wishid = $model_wish->add($data)))
{
$this->pop_warning($model_wish->get_error());
return;
}
$this->pop_warning('ok');
}
}
function edit()
{
$id = empty($_GET['wishid']) ? 0 : intval($_GET['wishid']);
if (!$id)
{
echo Lang::get("no_such_wish");
return;
}
if (!IS_POST)
{
$model_address =& m('wish');
$find_data = $model_address->find("wishid = {$id} AND user_id=" . $this->visitor->get('user_id'));
if (empty($find_data))
{
echo Lang::get('no_such_wish'); return;
}
$address = current($find_data); /* 当前位置 */
$this->_curlocal(LANG::get('member_center'), 'index.php?app=member',
LANG::get('my_address'), 'index.php?app=my_address',
LANG::get('edit_address')); $this->assign('act', 'edit');
$this->assign('wish', $address);
//$this->import_resource('mlselection.js, jquery.plugins/jquery.validate.js');
$this->assign('act', 'edit');
header('Content-Type:text/html;charset=' . CHARSET);
$this->display('wish.form.html');
}
else
{
/* 电话和手机至少填一项 */
if (!$_POST['wish_title'])
{
$this->pop_warning('wishtitle_required'); return;
}
$data = array(
'user_id' => $this->visitor->get('user_id'),
'wish_title'=> $_POST['wish_title'],
'way' => $_POST['way'],
'isdefault' => $_POST['default'],
'namee' => $_POST['names'],
'email' => $_POST['email'],
'sr' => $_POST['sr'],
'mycont' => $_POST['mycont'],
'myset' => $_POST['myset'],
);
$model_address =& m('wish');
$model_address->edit("wishid = {$id} AND user_id=" . $this->visitor->get('user_id'), $data);
if ($model_address->has_error())
{
$this->pop_warning($model_address->get_error()); return;
}
$this->pop_warning('ok', APP.'_'.ACT);
}
}
function drop()
{
$id = isset($_GET['id']) ? trim($_GET['id']) : 0;
if (!$id)
{
$this->show_warning('no_such_address'); return;
}
$ids = explode(',', $id);//获取一个类似array(1, 2, 3)的数组
$model_wish =& m('wish');
$drop_count = $model_wish->drop("wishid = " . $_GET['id'] . "");
if (!$drop_count)
{
/* 没有可删除的项 */
$this->show_warning('no_such_address'); return;
} if ($model_wish->has_error()) //出错了
{
$this->show_warning($model_address->get_error()); return;
} $this->show_message('drop_wish_successed');
}

输出日期:

{$rows.time|date:Y-m-d H:i:s}

$_SERVER['argv'][0]和$_SERVER['QUERY_STRING']一样  获取get参数,第一个返回数组且只有1维就包括全部参数,后者返回是字符串

$_SERVER['REQUEST_URI']  返回 /和当前文件全称及参数,如:http://localhost/cs3.php?a=1&b=2 返回 /cs3.php?a=1&b=2

$_SERVER['PHP_SELF'] 和  $_SERVER['SCRIPT_NAME'] 返回结果一样都是文件名称不带参数  如:/cs3.php