本文整理匯總了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('刪除失敗!');
}