當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Validate::isNullArray方法代碼示例

本文整理匯總了PHP中Validate::isNullArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validate::isNullArray方法的具體用法?PHP Validate::isNullArray怎麽用?PHP Validate::isNullArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Validate的用法示例。


在下文中一共展示了Validate::isNullArray方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: select

 protected function select(array $selectFields, array $param, $tables)
 {
     $limit = $order = $where = $fromTables = $like = '';
     $fields = implode(',', $selectFields);
     //處理篩選條件
     if (!Validate::isNullArray($param)) {
         $limit = isset($param['limit']) ? ' LIMIT  ' . $param['limit'] : '';
         $order = isset($param['order']) ? ' ORDER BY ' . $param['order'] : '';
         if (isset($param['where'])) {
             $isAnd = '';
             foreach ($param['where'] as $value) {
                 $isAnd .= $value . ' AND ';
             }
             $where = ' WHERE ' . substr($isAnd, 0, -4);
         }
         if (isset($param['like'])) {
             foreach ($param['like'] as $key => $value) {
                 $like = " WHERE {$key} LIKE '%{$value}%'";
             }
         }
     }
     //處理多表聯查
     foreach ($tables as $value) {
         $fromTables .= $value . ' ,';
     }
     $fromTables = substr($fromTables, 0, -1);
     $sql = "SELECT {$fields} FROM {$fromTables} {$where} {$like} {$order} {$limit} ";
     $stmt = $this->execute($sql);
     $result = array();
     while (!!($obj = $stmt->fetchObject())) {
         $result[] = $obj;
     }
     return Tool::setHtmlString($result);
 }
開發者ID:zhendeguoke1008,項目名稱:shop-1,代碼行數:34,代碼來源:DB.class.php

示例2: filter

 public function filter(array $fields)
 {
     $selectDate = array();
     if (Validate::isArray($_POST) && !Validate::isNullArray($_POST)) {
         foreach ($_POST as $key => $value) {
             if (Validate::inArray($key, $fields)) {
                 $selectDate[$key] = $value;
             }
         }
     }
     return $selectDate;
 }
開發者ID:zhendeguoke1008,項目名稱:shop-1,代碼行數:12,代碼來源:Request.class.php

示例3: filter

 public function filter(array $_fields)
 {
     $_selectData = array();
     if (Validate::isArray($_POST) && !Validate::isNullArray($_POST)) {
         //篩選準備入庫的字段和數據
         foreach ($_POST as $_key => $_value) {
             if (Validate::inArray($_key, $_fields)) {
                 $_selectData[$_key] = $_value;
             }
         }
     }
     return $_selectData;
 }
開發者ID:yjf0503,項目名稱:Mall,代碼行數:13,代碼來源:Request.class.php

示例4: setHtmlString

 public static function setHtmlString($_data)
 {
     $_string = null;
     if (Validate::isArray($_data)) {
         if (Validate::isNullArray($_data)) {
             return $_data;
         }
         foreach ($_data as $_key => $_value) {
             $_string[$_key] = self::setHtmlString($_value);
         }
     } elseif (is_object($_data)) {
         foreach ($_data as $_key => $_value) {
             $_string->{$_key} = self::setHtmlString($_value);
         }
     } else {
         $_string = htmlspecialchars($_data);
     }
     return $_string;
 }
開發者ID:yjf0503,項目名稱:Mall,代碼行數:19,代碼來源:Tool.class.php

示例5: fileUser

 public function fileUser($file)
 {
     foreach ($file as $key => $value) {
         if (!is_object($value)) {
             $user = parent::select(array('id,user,thumb'), array('where' => array("thumb='upload/{$_GET['file']}/{$value}'")));
             if (!Validate::isNullArray($user)) {
                 $user[0]->pic = $value;
                 $user[0]->link = 'user';
                 $user[0]->name = $user[0]->user . '[<strong style="color:green;font-size:12px;">會員頭像</strong>]';
                 $file[$key] = $user[0];
             }
         }
     }
     return $file;
 }
開發者ID:zhendeguoke1008,項目名稱:shop-1,代碼行數:15,代碼來源:UserModel.class.php

示例6: select

 protected function select($_tables, array $_field, array $_param = array())
 {
     $_limit = '';
     $_order = '';
     $_where = '';
     $_like = '';
     if (Validate::isArray($_param) && !Validate::isNullArray($_param)) {
         $_limit = isset($_param['limit']) ? 'LIMIT ' . $_param['limit'] : '';
         $_order = isset($_param['order']) ? 'ORDER BY ' . $_param['order'] : '';
         $_where = '';
         if (isset($_param['where'])) {
             foreach ($_param['where'] as $_key => $_value) {
                 $_where .= $_value . ' AND ';
             }
             $_where = 'WHERE ' . substr($_where, 0, -4);
         }
         if (isset($_param['like'])) {
             foreach ($_param['like'] as $_key => $_value) {
                 $_like = "WHERE {$_key} LIKE '%{$_value}%'";
             }
         }
     }
     $_selectFields = implode(',', $_field);
     $_table = isset($_tables[1]) ? $_tables[0] . ',' . $_tables[1] : $_tables[0];
     $_sql = "SELECT {$_selectFields} FROM {$_table} {$_where} {$_like} {$_order} {$_limit} ";
     $_stmt = $this->execute($_sql);
     $_result = array();
     while (!!($_objs = $_stmt->fetchObject())) {
         $_result[] = $_objs;
     }
     return Tool::setHtmlString($_result);
 }
開發者ID:yjf0503,項目名稱:Mall,代碼行數:32,代碼來源:DB.class.php

示例7: getNavId

 private function getNavId()
 {
     $this->_tables = array(DB_PREFIX . 'nav');
     //商品副類id數組
     $_idArr = parent::select(array('id'), array('where' => array("sid='{$this->_R['navid']}'")));
     $_id = '';
     //副類處理
     if (Validate::isNullArray($_idArr)) {
         $_id = $this->_R['navid'];
     } else {
         foreach ($_idArr as $_key => $_value) {
             $_id .= $_value->id . ',';
         }
         $_id = substr($_id, 0, -1);
     }
     $this->_tables = array(DB_PREFIX . 'goods');
     return $_id;
 }
開發者ID:yjf0503,項目名稱:Mall,代碼行數:18,代碼來源:GoodsModel.class.php

示例8: getNavId

 private function getNavId()
 {
     //商品副類id數組
     $_idArr = parent::select(array('id'), array('where' => array("sid='{$this->_R['navid']}'")));
     $_id = array();
     //副類處理
     if (Validate::isNullArray($_idArr)) {
         $_id[] = $this->_R['navid'];
     } else {
         foreach ($_idArr as $_key => $_value) {
             $_id[] .= $_value->id;
         }
     }
     return $_id;
 }
開發者ID:yjf0503,項目名稱:Mall,代碼行數:15,代碼來源:NavModel.class.php

示例9: fileRotator

 public function fileRotator($file)
 {
     foreach ($file as $key => $value) {
         if (!is_object($value)) {
             $rotator = parent::select(array('id,thumb,name'), array('where' => array("thumb='upload/{$_GET['file']}/{$value}'")));
             if (!Validate::isNullArray($rotator)) {
                 $rotator[0]->pic = $value;
                 $rotator[0]->link = 'index';
                 $rotator[0]->name = $rotator[0]->name . '[<strong style="color:green;font-size:12px;">輪播器</strong>]';
                 $file[$key] = $rotator[0];
             }
         }
     }
     return $file;
 }
開發者ID:zhendeguoke1008,項目名稱:shop-1,代碼行數:15,代碼來源:RotatorModel.class.php

示例10: fileGoods

 public function fileGoods($file)
 {
     foreach ($file as $key => $value) {
         if (!is_object($value)) {
             $goods = parent::select(array('id,nav,name'), array('where' => array("thumb='upload/{$_GET['file']}/{$value}' OR\r\n\t\t\t\t\t\tthumb_small='upload/{$_GET['file']}/{$value}' OR\r\n\t\t\t\t\t\t\t\tcontent LIKE '%upload/{$_GET['file']}/{$value}%'")));
             if (!Validate::isNullArray($goods)) {
                 $goods[0]->pic = $value;
                 $goods[0]->name = $goods[0]->name . '[<strong style="color:green;font-size:12px;">商品</strong>]';
                 $file[$key] = $goods[0];
             }
         }
     }
     return $file;
 }
開發者ID:zhendeguoke1008,項目名稱:shop-1,代碼行數:14,代碼來源:GoodsModel.class.php

示例11: getFrontAttr

 public function getFrontAttr()
 {
     //用於存放所有的符合查詢條件的導航信息id
     $array = array();
     //獲得全部的導航
     $allNav = parent::select(array('id', 'sid'));
     foreach ($allNav as $key => $value) {
         //通過主導航保存子導航id
         if ($value->sid == $this->R['navid']) {
             $array[] = $value->id;
         } else {
             //保存子導航id
             $array[] = $this->R['navid'];
         }
     }
     $this->tables = array(DB_FREFIX . 'attr');
     //查詢屬性信息
     $allAttr = parent::select(array('name', 'item', 'id', 'nav'));
     //用於保存最終生成的屬性信息
     $frontAttr = array();
     foreach ($allAttr as $key => $value) {
         //屬性中的nav字段轉為數組
         $value->nav = explode(',', $value->nav);
         //如果導航id與屬性nav集合之間有交集則證明該導航有相關屬性信息
         if (array_intersect($array, $value->nav)) {
             //轉屬性為數組
             $value->item = explode('|', $value->item);
             //轉url屬性為數組
             $getAttr = explode('-', $this->R['attr']);
             //用於存放每組屬性與url的交集,屬性每組隻有一個位於url中,所以該數組永遠隻有一個元素
             $attrArray = array_intersect($getAttr, $value->item);
             //顯示“全部”是否被選中,用flag做判定,如果URL中已有信息為該屬性的則證明已有屬性被選中,flag為TRUE
             $value->flag = $attrArray ? true : false;
             //存放前台顯示全部按鈕的具體href信息 顯示全部即為去掉當前屬性中的相關信息
             $value->all = implode('-', array_diff($getAttr, $value->item)) ? '&attr=' . implode('-', array_diff($getAttr, $value->item)) : null;
             //該循環用於過濾url中由於多次點擊而重複出現的attr屬性
             foreach ($value->item as $k => $v) {
                 if (!Validate::isNullArray($attrArray)) {
                     //該處$attrArray永遠隻有一個元素,因為attr中相關屬性隻能有一個
                     foreach ($attrArray as $val) {
                         $attrArray[0] = $val;
                     }
                     //如果url中已有相關屬性值用最新的替換之,temp用於存放生成的url地址欄信息
                     $value->temp[] = $temp = str_replace($attrArray[0], $v, $this->R['attr']);
                 } elseif (!isset($this->R['attr']) || empty($this->R['attr'])) {
                     //初次加載URL中沒有相關attr時
                     $value->temp[] = $v;
                 } elseif (Validate::isNullArray($attrArray)) {
                     //用於不同屬性之間的鏈接
                     $value->temp[] = $this->R['attr'] . '-' . $v;
                 }
             }
             //將item與temp鏈接item為key,temp為值
             $value->attr = array_combine($value->item, $value->temp);
             $frontAttr[] = $value;
         }
     }
     return $frontAttr;
 }
開發者ID:zhendeguoke1008,項目名稱:shop-1,代碼行數:59,代碼來源:NavModel.class.php


注:本文中的Validate::isNullArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。