带分页数据的DB::page
@param string $table
@param $field
@param mixed $condition
@param int $length
@param int $pageparm
@param bool $retobj
@return array
172416
public static function page($table, $field, $condition = '', $pageparm = 0, $length = 18, $retobj = false)
    {
        $db = self::Using(self::$using_dbo_id);
        return $db->page($table, $field, $condition, $pageparm, $length, $retobj);
    }
1046695
function insertSiblingData($FieldValueArray=array(),$ConditionString=null,$Rest=null)
    {
		$this->lock();
    	//Find the Sibling
        $Arguments=func_get_args();
        array_shift($Arguments); //first argument, the array
        array_shift($Arguments);
        if ($ConditionString) $ConditionString="WHERE $ConditionString";
        $Query="SELECT {$this->right()} AS `Right`".
        	" FROM {$this->table()} $ConditionString";

        array_unshift($Arguments,$Query);
        $Sibl=call_user_func_array("Jf::sql",$Arguments);

        $Sibl=$Sibl[0];
        if ($Sibl==null)
        {
            $Sibl["Left"]=$Sibl["Right"]=0;
        }
        Jf::sql("UPDATE {$this->table()} SET {$this->right()} = {$this->right()} + 2 WHERE {$this->right()} > ?",$Sibl["Right"]);
        Jf::sql("UPDATE {$this->table()} SET {$this->left()} = {$this->left()} + 2 WHERE {$this->left()} > ?",$Sibl["Right"]);

        $FieldsString=$ValuesString="";
        $Values=array();
        if ($FieldValueArray)
        foreach($FieldValueArray as $k=>$v)
        {
            $FieldsString.=",";
            $FieldsString.="`".$k."`";
            $ValuesString.=",?";
            $Values[]=$v;
        }

        $Query= "INSERT INTO {$this->table()} ({$this->left()},{$this->right()} $FieldsString) ".
        	"VALUES(?,? $ValuesString)";
        array_unshift($Values,$Sibl["Right"]+2);
        array_unshift($Values,$Sibl["Right"]+1);
        array_unshift($Values,$Query);

        $Res=call_user_func_array("Jf::sql",$Values);
		$this->unlock();
        return $Res;
    }
73052
public static function findAll($table, $field = '*', $condition = '', $index = null, $retobj = false)
    {
        $db = self::Using(self::$using_dbo_id);
        return $db->findAll($table, $field, $condition, $index, $retobj);
    }
1233341
public function inc($table, $data, $condition)
    {
        $collection = $this->db->selectCollection($table);
        $result = $collection->update(
            MongoQueryBuilder::where($condition),
            array('$inc' => self::filterData($data)),
            $this->getOptions());

        return ($result['ok'] == 1 && $result['n'] > 0);
    }
422786
public function fieldSelect($table, $fields, $where, $orderBy = null)
    {
        $table = $this->getTableName($table);

        $query = "SELECT ";

        if (substr($this->mode, 0, 5) === "mssql") {
            $query .= "TOP 1 ";
        }

        $query .= $this->selectFields($fields);

        $query .= " FROM " . $table . " ";

        $params = null;
        if ($where !== self::NO_WHERE_CLAUSE) {
            $query .= "WHERE " . $this->where($where, $params);
        }

        if ($orderBy) {
            $query .= $this->orderBy($orderBy) . " ";
        }

        switch ($this->mode) {

            case "mysql":
            case "postgres":
            case "redshift":
            case "sqlite":
                $query .= "LIMIT 1";
                break;

            case "odbc":
                $query .= "FETCH FIRST 1 ROW ONLY";
                break;
        }

        return $this->query($query, $params)->fetch();
    }
32241
public function find($table, $fields = null, $where = null, $order = null, $limit = null, $offset = null, $array = array(), $fetchMode = \PDO::FETCH_ASSOC)
     {
         $sql = ' SELECT '.(($fields) ?? '*').' FROM '.(($table)).(($where) ? ' WHERE '.$where : ' ')
            .(($limit) ? ' LIMIT '.$limit : ' ')
            .(($offset && $limit) ? ' OFFSET '.$offset : ' ')
            .(($order) ? ' ORDER BY '.$order : ' ');

         $stmt = $this->conn->prepare($sql);

         foreach ($array as $key => $values) {
             return  $stmt->bindValue("$key", $values);
         }
         $stmt->execute();

         do {
             return $stmt->fetchAll($fetchMode);
         } while (
            $stmt->nextRowset());
         $stmt->close();
     }
841851
public function get_values_count($table, $field, array $where = [], $limit, $start, $php = false)
  {
		if ( ( $table = $this->table_full_name($table, 1) )  && ( $m = $this->db->modelize($table) ) && \count($m['fields']) > 0 )
		{
			$r = '';
			if ( $php ){
				$r .= '$db->query("';
			}
      if ( !isset($m['fields'][$field]) ){
        die("The column $field doesn't exist in $table");
      }
			$r .= "SELECT COUNT(*) AS num, `$field` AS val FROM $table";
			if ( \count($where) > 0 ){
        $r .= PHP_EOL . $this->db->get_where($where, $table);
      }
      $r .= PHP_EOL . "GROUP BY `$field`";
      $r .= PHP_EOL . "ORDER BY `$field`";
      if ( $limit ){
  			$r .= PHP_EOL . $this->get_limit([$limit, $start]);
      }
			if ( $php ){
				$r .= '");';
			}
			return $r;
		}
		return false;
  }
506210
public function select($table, $fields = "*", $where = ' ', $order = '', $limit = null, $offset = null, $array = array (), $fetchMode)
    {
        // TODO: Implement select() method.
    }
881546
public function where($field, $table, $value) {
        static $i = 0;
        $sql = self::resolve_field($field, $table) . ' ';

        if ($value === null) {
            $sql .= 'IS NULL';

        } else {
            $param = 'where' . $i++;
            $sql .= " = :$param";
            $this->params[$param] = $value;
        }

        $this->where[] = $sql;
    }
935646
public static function find(array $conditions = [], array $order = [], $limit = 0, $page = 0)
    {
        /**
         * Convert order parameters to Mongo format
         */
        $order = self::parseOrderParameters($order);
        $offset = $limit * ($page > 0 ? $page - 1 : 0);

        $data = self::entity()->getDatabase()->find(static::$collection, $conditions, $order, $limit, $offset);
        $parameters = [
            'conditions' => $conditions,
            'order'      => $order,
            'limit'      => $limit,
            'offset'     => $offset
        ];

        return new EntityCollection(get_called_class(), $data, $parameters);
    }
1112361
public function delete($table, $condition, array $params = [])
    {
        $request = $this->db->getQueryBuilder()->delete($table, $condition, $params);

        return $this->setRequest($request);
    }
122258
public function selectBy($field, $value, $table = null)
	{
		if(null === $table)
		{
			$table = $this->tableName();
		}
		return $this->where(array((false === $table ? '' : ($table . '.')) . $field=>$value))->select();
	}
1189628
public static function getListByCondition($condition = '', $params = [], $order = 'group_id desc', $page = 1, $pageSize = 20)
    {
        $pagination = new Pagination();
        $pagination->setPage($page);
        $pagination->setPageSize($pageSize);
        $pagination->totalCount = static::find()->andWhere($condition, $params)->count(1);
        $list = static::find()
            ->andWhere($condition, $params)
            ->offset($pagination->getOffset() - $pagination->getPageSize())
            ->limit($pagination->getPageSize())
            ->orderBy($order)
            ->asArray()
            ->all();

        return [
            'paginationObj' => $pagination,
            'pagination' => [
                'currentPage' => $page,
                'pageSize' => $pageSize,
                'pageCount' => $pagination->getPageCount(),
                'totalCount' => $pagination->totalCount,
            ],
            'list' => $list,
        ];
    }
1240519
function InnerJoin(Table $table, Condition $condition, $prepend = false)
    {
        return $this->Join($table, JoinType::Inner(), $condition, $prepend);
    }
1367519
public function getWhereIn(string $table, string $field, array $values): array
    {
        try {
            $this->db->beginTransaction();

            $query = "SELECT * FROM $table WHERE $field IN (" . implode(',', $values) . ")";

            /** @var PDOStatement $stmt */
            $stmt = $this->db->prepare($query);
            $stmt->execute();

            $this->db->commit();
            $result = $stmt->fetchAll();

            if ($result === false) {
                throw new NotFoundException($values . ' not found.');
            }

            return $result;
        } catch (PDOException $e) {
            $this->db->rollBack();
            throw new PDOException($e);
        }
    }
82133
public function max($table, $field, $conditions = false)
    {
        return $this->executeAggregate('MAX', $table, $field, $conditions);
    }
715661
public function get($conditions = [], $requiredField = [], $page = 0)
    {

        $searchParams['index'] = $this->index;
        $searchParams['type'] = $this->type;
        $searchParams['size'] = $this->maxResultsSize;
        $searchParams['from'] = $page * $this->maxResultsSize;
        $searchParams['body']['query']['bool']['must'] = [];
        $searchParams['_source_exclude']= ['PAG*'];

        $searchParams['body']['highlight']['order'] = 'score';
        $searchParams['body']['highlight']['fields'] = ['PAGE_*' => ['number_of_fragments' => 3], 'PAG_*' => ['number_of_fragments' => 3]];
        $searchParams['body']['highlight']['pre_tags'] = ['<strong>'];
        $searchParams['body']['highlight']['post_tags'] = ['</strong>'];

        foreach ($requiredField as $field) {
            $searchParams['body']['query']['bool']['must'][]['exists'] = ['field' => $field];
        }

        $filter = $this->makeFilterCondition($conditions);

        if(!empty($filter))$searchParams['body']['query']['bool']['must'][] = $filter;

        if($this->isModel)return $this->model->hydrateElasticsearchResult($this->client->search($searchParams));
        else return $this->client->search($searchParams);

    }