コード例 #1
0
 public static function get($inputData = array())
 {
     $limitQuery = "";
     $limitShow = isset($inputData['limitShow']) ? $inputData['limitShow'] : 0;
     $limitPage = isset($inputData['limitPage']) ? $inputData['limitPage'] : 0;
     $limitPage = (int) $limitPage > 0 ? $limitPage : 0;
     $limitPosition = $limitPage * (int) $limitShow;
     $limitQuery = (int) $limitShow == 0 ? '' : " limit {$limitPosition},{$limitShow}";
     $limitQuery = isset($inputData['limitQuery']) ? $inputData['limitQuery'] : $limitQuery;
     $field = "requestid,userid,total_request,date_added,status,comments";
     $selectFields = isset($inputData['selectFields']) ? $inputData['selectFields'] : $field;
     $whereQuery = isset($inputData['where']) ? $inputData['where'] : '';
     $orderBy = isset($inputData['orderby']) ? $inputData['orderby'] : 'order by requestid desc';
     $result = array();
     $command = "select {$selectFields} from " . Database::getPrefix() . "request_payments {$whereQuery}";
     $command .= " {$orderBy}";
     $queryCMD = isset($inputData['query']) ? $inputData['query'] : $command;
     $queryCMD .= $limitQuery;
     $cache = isset($inputData['cache']) ? $inputData['cache'] : 'yes';
     $cacheTime = isset($inputData['cacheTime']) ? $inputData['cacheTime'] : 1;
     if ($cache == 'yes') {
         // Load dbcache
         $loadCache = DBCache::get($queryCMD, $cacheTime);
         if ($loadCache != false) {
             $loadCache = unserialize($loadCache);
             return $loadCache;
         }
         // end load
     }
     $query = Database::query($queryCMD);
     if (isset(Database::$error[5])) {
         return false;
     }
     $inputData['isHook'] = isset($inputData['isHook']) ? $inputData['isHook'] : 'yes';
     if ((int) $query->num_rows > 0) {
         while ($row = Database::fetch_assoc($query)) {
             if (isset($row['comments'])) {
                 $row['comments'] = String::decode($row['comments']);
             }
             if (isset($row['date_added'])) {
                 $row['date_addedFormat'] = Render::dateFormat($row['date_added']);
             }
             if ($inputData['isHook'] == 'yes') {
                 if (isset($row['comments'])) {
                     $row['comments'] = Shortcode::load($row['comments']);
                 }
             }
             $result[] = $row;
         }
     } else {
         return false;
     }
     // Save dbcache
     DBCache::make(md5($queryCMD), $result);
     // end save
     return $result;
 }