Ejemplo n.º 1
0
 /**
  * 
  * @param mixed $lastPage
  * @param \Sooh\DB\Interfaces\All $db
  */
 protected function loopGetRecordsPage_buildWhere($db)
 {
     $lastPage = $this->lastPage;
     $sort_field_type = $this->sort_field_type;
     $sortMethod = array(0 => array('sort' => ']', 'rsort' => '['), -1 => array('sort' => '<', 'rsort' => '>'), 1 => array('sort' => '>', 'rsort' => '<'));
     $sorValIndex = array(0 => 0, -1 => 0, 1 => 1);
     if (sizeof($sort_field_type) == 1) {
         //单键
         $w = array();
         if (!empty($lastPage['_last_'])) {
             $k = key($sort_field_type);
             $sort = current($sort_field_type);
             $w[$k . $sortMethod[$this->pageStep][$sort]] = $lastPage['_last_']['_' . $k . '_'][$sorValIndex[$this->pageStep]];
             //echo ">>$k $sort $pageForward ".$sortMethod[$pageForward][$sort]." ".$lastPage['_'.$k.'_'][$pageForward]."\n";
             //echo ">>1>>".json_encode($w)."\n";
         }
         if (is_array($lastPage['where'])) {
             $w = $this->loopGetRecordsPage_mergeWhere($w, $lastPage['where']);
             //echo ">>2>>".json_encode($w)."\n";
         }
         //echo ">>3>>".json_encode($w)."\n";
         $where = $w;
     } else {
         //双键, 【=,>】,【>,null】
         $wEq = array();
         $wCmp = array();
         if (!empty($lastPage['_last_'])) {
             $k1 = key($sort_field_type);
             $sort1 = current($sort_field_type);
             array_shift($sort_field_type);
             $k2 = key($sort_field_type);
             $sort2 = current($sort_field_type);
             $wEq[$k1 . '='] = $lastPage['_last_']['_' . $k1 . '_'][$sorValIndex[$this->pageStep]];
             $wEq[$k2 . $sortMethod[$this->pageStep][$sort2]] = $lastPage['_last_']['_' . $k2 . '_'][$sorValIndex[$this->pageStep]];
             $wCmp[$k1 . $sortMethod[$this->pageStep][$sort1]] = $lastPage['_last_']['_' . $k1 . '_'][$sorValIndex[$this->pageStep]];
             if (is_array($lastPage['where'])) {
                 $wEq = $this->loopGetRecordsPage_mergeWhere($wEq, $lastPage['where']);
                 $wCmp = $this->loopGetRecordsPage_mergeWhere($wCmp, $lastPage['where']);
             }
             $where = $db->newWhereBuilder();
             $where->init('OR');
             $where->append(null, $db->newWhereBuilder()->append($wEq));
             $where->append(null, $db->newWhereBuilder()->append($wCmp));
             $where = $where->end();
         } else {
             if (is_array($lastPage['where'])) {
                 $where = $lastPage['where'];
             } else {
                 $where = $wEq;
             }
         }
     }
     //echo "WHERE=";
     //var_dump($where);
     return $where;
 }
Ejemplo n.º 2
0
 /**
  * 加载数据(某月)
  * @param \Sooh\DB\Interfaces\All  $db
  * @param int $ymd
  * @param string $mainType
  * @param string $subType
  * @return array [ymd=>[rptdata,flg1,flg2,flg3],ymd=>[rptdata,flg1,flg2,flg3]....]
  */
 public function loadMonth($db, $ymd, $mainType, $subType)
 {
     $ret = array();
     if ($ymd > 10020101) {
         $ymd = $ymd - $ymd % 100;
     } else {
         $ymd = $ymd * 100;
     }
     //201501
     $rs = $db->getRecords($this->tbName, 'ymd,rptdata,flg1,flg2,flg3', array('mainType' => $mainType, 'subType' => $subType, 'ymd>' => $ymd, 'ymd<' => $ymd + 100));
     foreach ($rs as $r) {
         $r['rptdata'] = json_decode($r['rptdata'], true);
         $ymd = $r['ymd'];
         unset($r['ymd']);
         $ret[$ymd] = $r;
     }
     ksort($ret);
     return $ret;
 }
Ejemplo n.º 3
0
 /**
  *
  * @param \Sooh\DB\Interfaces\All $db
  * @param string $tb
  */
 public function __getPkeyByAccountId($db, $tb)
 {
     if (!is_array($this->__accountId)) {
         $r = $db->getRecord($tb, 'loginName,cameFrom', array('accountId' => $this->__accountId));
         if (!empty($r)) {
             $this->__accountId = $r;
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * 建表
  * @param \Sooh\DB\Interfaces\All $db
  * @param string $tb
  */
 protected function createTable($db, $tb)
 {
     $db->ensureObj($tb, array('appType' => 'varchar(10) not null', 'pkey' => 'varchar(50) not null', 'skey' => 'varchar(50) not null', 'chk' => 'varchar(36) not null', 'contractId' => 'bigint not null default 0', 'copartnerAbs' => 'varchar(16)', 'ymd' => 'int not null default 0', 'hhiiss' => 'int not null default 0', 'expired' => 'int not null default 0', 'copartnerData' => 'varchar(128)', 'copartnerUrl' => 'varchar(512)', 'copartnerRet' => 'varchar(512)', 'callbackRetry' => 'bigint unsigned not null default 0', $this->fieldName_verid => 'int not null default 0'), array('appType', 'pkey', 'skey'), array('dtretry' => array('callbackRetry')));
 }
Ejemplo n.º 5
0
 /**
  * loopGetRecords调用,获取符合条件的记录
  * @param \Sooh\DB\Interfaces\All $db
  * @param string $tb
  */
 protected static function loopGetRecordsPage_getRecords($db, $tb)
 {
     foreach (static::$tmpVar['where'] as $realWhere) {
         static::$tmpVar['rs'][] = $db->getRecords($tb, '*', $realWhere, static::$tmpVar['sort'], static::$tmpVar['pagesize']);
     }
 }