コード例 #1
0
ファイル: core.php プロジェクト: umaxfun/x4m
 public function run()
 {
     $selectQs = $this->getSelectQueryString();
     $whereQs = $this->getWhereQueryString();
     if (!isset($this->query['selectStruct']) && isset($this->query['selectParams'])) {
         $this->query['selectStruct'] = array('id');
         $selectQs['selectStructString'] = 'id';
     }
     if (isset($selectQs['selectStructString'])) {
         $queryStr = 'SELECT ' . $selectQs['selectStructString'] . ' FROM `' . $this->treeStructName . '` a ';
     }
     if (isset($whereQs['whereStructString'])) {
         $queryStr .= ' WHERE ' . $whereQs['whereStructString'];
     }
     if (isset($this->query['sortByStruct'])) {
         $queryStr .= 'order by ' . $this->query['sortByStruct']['element'] . ' ' . $this->query['sortByStruct']['order'];
     } else {
         $queryStr .= ' order by rate';
     }
     if (!isset($this->query['delete'])) {
         $mark = Common::createMark($this->query);
         if ($this->enableCache && ($result = xCache::serializedRead($this->cacheDir, $mark, $this->cacheTimeout))) {
             unset($this->query);
             return $result;
         }
     }
     if ($queryStr) {
         $pdoResult = $this->PDO->query($queryStr);
         if ($nStructResults = $pdoResult->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_ASSOC)) {
             $nStructResults = array_map('reset', $nStructResults);
         }
     }
     // get all params as nodes
     if (isset($whereQs['whereParamsString'])) {
         $queryStr = 'select node_name, count( node_name ) as CCOUNT from ' . $this->treeParamName . ' b  WHERE ' . $whereQs['whereParamsString'];
         $result = $this->PDO->query($queryStr);
         $nParamsResults = $result->fetchAll(PDO::FETCH_COLUMN, 0);
         // no intersection no result
         if ($nStructResults && $nParamsResults && ($nodesIntersect = array_intersect($nParamsResults, array_keys($nStructResults)))) {
             foreach ($nodesIntersect as $k => $v) {
                 $structResults[$v] = $nStructResults[$v];
             }
             $nStructResults = $structResults;
         } else {
             $this->query = array();
             return;
         }
     } else {
         $nodesIntersect = array_keys($nStructResults);
     }
     if (isset($this->query['delete'])) {
         return $this->deleteProcess($nodesIntersect);
     }
     if (isset($this->query['selectParams'])) {
         $paramsResult = $this->getParams($nodesIntersect);
         while ($pf = $paramsResult->fetch(PDO::FETCH_ASSOC)) {
             $nodesParams[$pf['node_name']][$pf['parameter']] = $pf['value'];
         }
     } else {
         $nodesParams = null;
     }
     if ($pdoResult) {
         if (isset($this->query['sortByParam'])) {
             $nSortResults = $this->sortByParam(array_keys($nStructResults));
             foreach ($nSortResults as $k) {
                 $sorted[$k] = $nStructResults[$k];
             }
             $nStructResults = $sorted;
         }
         $result = $this->formatProcess($nStructResults, $nodesParams);
         if ($this->enableCache && !$this->query['delete']) {
             xCache::serializedWrite($result, $this->cacheDir, $mark, $this->cacheTimeout);
         }
         unset($this->query);
         return $result;
     }
 }
コード例 #2
0
ファイル: xFileSession.class.php プロジェクト: umaxfun/x4m
 function serialize_session()
 {
     xCache::serializedWrite($this->data, 'session', $this->sessionid);
 }