本文整理汇总了PHP中parent::Model方法的典型用法代码示例。如果您正苦于以下问题:PHP parent::Model方法的具体用法?PHP parent::Model怎么用?PHP parent::Model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parent
的用法示例。
在下文中一共展示了parent::Model方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$type = $_REQUEST['type'];
$key = $_REQUEST['key'];
if (!get_magic_quotes_gpc()) {
$key = addslashes($key);
}
$sql = array();
if (!empty($key) && !empty($type)) {
switch (true) {
case $type == 'name':
$sql['name'] = array('like', "%{$key}%");
//名称模糊查找
break;
case $type == 'id':
$sql['id'] = intval($key);
//名称模糊查找
break;
case $type == 'brand':
$sql['brand'] = $key;
//品牌查找
break;
case $type == 'cateid':
$sql['cateid'] = $key;
//类别查找
break;
case $type == 'pricelt':
$sql['price'] = array('lt', $key);
//价格小于
break;
case $type == 'pricegt':
$sql['price'] = array('gt', $key);
//价格大于
break;
}
} elseif (!empty($key)) {
$sql['name'] = array('like', "%{$key}%");
//名称模糊查找
$sql['serial'] = array('like', "%{$key}%");
//名称模糊查找
$sql['id'] = intval($key);
$sql['_logic'] = 'or';
}
$map['isdown'] = array('neq', '1');
parent::$Model = D("Products");
if (isset($_REQUEST['key'])) {
$_SESSION['map'] = $sql;
} elseif (isset($_REQUEST['map'])) {
$sql = $_SESSION['map'];
}
$this->disp_text = "Search";
parent::$Model->_list($this->view, $sql, 'sort', false);
$this->display();
}
示例2: D
function contact_us()
{
$article_cache = md5('article_conatct_us');
if (S($article_cache) == '') {
parent::$Model = D('Article');
$map['title'] = 'Contact-us';
$list = parent::$Model->where($map)->find();
$list['title'] = str_replace("-", " ", $list['title']);
S($article_cache, $list);
}
$list = S($article_cache);
$this->assign($list);
$this->pagetitle = $list['title'];
$this->pagekeywords = $list['keywords'];
$this->pagedesc = $list['description'];
$this->display("Empty:contact_us");
}
示例3: delProducts
function delProducts()
{
$id = intval($_REQUEST['id']);
if ($id) {
//获得所有子类
parent::$Model = D('Cate');
$cate_in_id = implode(',', parent::$Model->getChildren($id, $id));
if ($cate_in_id) {
//获得所有产品
parent::$Model = D('Products');
$map['cateid'] = array('in', $cate_in_id);
$count = parent::$Model->where($map)->count();
$j = $k = $l = 0;
if ($count) {
$list = parent::$Model->where($map)->select();
$products_ids = implode(',', array_map('reset', parent::$Model->field('id')->where($map)->select()));
if ($products_ids) {
//删除产品属性
parent::$Model = D('Products_attr');
parent::$Model->del_attrs($products_ids);
}
parent::$Model = D('Products_gallery');
foreach ($list as $v) {
$v['bigimage'] = auto_charset($v['bigimage'], 'utf-8', 'gbk');
$v['smallimage'] = auto_charset($v['smallimage'], 'utf-8', 'gbk');
if (file_exists($v['bigimage'])) {
$j++;
unlink($v['bigimage']);
}
if (file_exists($v['smallimage'])) {
unlink($v['smallimage']);
}
//删除产品相册
$g = parent::$Model->where(array('pid' => $v['id']))->find();
$g['img_url'] = auto_charset($v['img_url'], 'utf-8', 'gbk');
$g['thumb_url'] = auto_charset($v['thumb_url'], 'utf-8', 'gbk');
if (file_exists($v['img_url'])) {
$k++;
unlink($v['img_url']);
}
if (file_exists($v['thumb_url'])) {
unlink($v['thumb_url']);
}
parent::$Model->where(array('pid' => $v['id']))->delete();
//删除关联产品数据
parent::$Model = D("Products_related");
parent::$Model->where(array("products_id" => $v['id']))->delete();
$l++;
}
//最后删除产品
parent::$Model = D('Products');
parent::$Model->where($map)->delete();
$str = "共删除了 " . $count . " 个产品,其中删除了" . $j . "个产品图片 " . $k . " 个相关图片 " . $l . " 个关联产品!";
$this->success($str);
} else {
$this->error('没有产品数据!');
}
} else {
$this->error('请选择类别!');
}
} else {
$this->error('请选择类别!');
}
}
示例4: doDelRelated
function doDelRelated()
{
parent::$Model = D('Products_related');
if ($_REQUEST['id']) {
$map['id'] = array('in', $_REQUEST['id']);
$j = parent::$Model->where($map)->delete();
$this->success('删除了' . $j . '个关联产品!');
}
$this->error('删除失败!');
}