获取数据.

@param array                         $con      条件.
@param string                        $db       数据库
@param \wulaphp\router\UrlParsedInfo $pageInfo 分页信息
@param array                         $tplvars  模板变量.

@return CtsData 数据.
3193
public final function getList($con, $db, $pageInfo, $tplvars) {
        try {
            $dbx = App::db($db);

            $data = $this->getData($con, $dbx, $pageInfo, $tplvars);
            if ($data instanceof CtsData) {
                return $data;
            }
        } catch (\Exception $e) {

        }

        return new CtsData([], 0);
    }
743456
private void doGetCFXTags() throws PageException {
	Map map = config.getCFXTagPool().getClasses();
	lucee.runtime.type.Query qry = new QueryImpl(
		new String[] { "displayname", "sourcename", "readonly", "isvalid", "name", "procedure_class", "procedure_bundleName", "procedure_bundleVersion", "keep_alive" },
		map.size(), "query");
	Iterator it = map.keySet().iterator();

	int row = 0;
	while (it.hasNext()) {
	    row++;
	    CFXTagClass tag = (CFXTagClass) map.get(it.next());

	    qry.setAt("displayname", row, tag.getDisplayType());
	    qry.setAt("sourcename", row, tag.getSourceName());
	    qry.setAt("readonly", row, Caster.toBoolean(tag.isReadOnly()));
	    qry.setAt("isvalid", row, Caster.toBoolean(tag.isValid()));

	    if (tag instanceof JavaCFXTagClass) {
		JavaCFXTagClass jtag = (JavaCFXTagClass) tag;
		qry.setAt(KeyConstants._name, row, jtag.getName());
		qry.setAt("procedure_class", row, jtag.getClassDefinition().getClassName());
		qry.setAt("procedure_bundleName", row, jtag.getClassDefinition().getName());
		qry.setAt("procedure_bundleVersion", row, jtag.getClassDefinition().getVersionAsString());
	    }

	}
	pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
    }
895722
public function selectPage($page = 1,$show = 10,&$recordCount = null)
	{
		if($this->isSelectBefore)
		{
			$this->__selectBefore();
		}
		$option = $this->operationOption;
		if(null === $recordCount)
		{
			if('Mysql' === $this->db->getType())
			{
				$isMysqlCount = true;
			}
			else
			{
				// 去除排序，提高效率
				if(isset($this->operationOption['order']))
				{
					unset($this->operationOption['order']);
				}
				$recordCount = $this->count();
				$this->operationOption = $option;
			}
		}
		if(isset($isMysqlCount) && $isMysqlCount)
		{
			$this->operationOption['fieldBefore'] = array('SQL_CALC_FOUND_ROWS');
		}
		$this->db->operationOption = $this->page($page,$show)->getOption();
		$data = $this->db->query();
		if(isset($isMysqlCount) && $isMysqlCount)
		{
			$recordCount = $this->db->getScalar('select FOUND_ROWS()');
		}
		$this->__selectAfter($data,$option);
		return $data;
	}
390460
protected function doInsert(PropelPDO $con)
    {
        $modifiedColumns = array();
        $index = 0;


         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(UserRolePeer::USER_ID)) {
            $modifiedColumns[':p' . $index++]  = '`user_id`';
        }
        if ($this->isColumnModified(UserRolePeer::ROLE_ID)) {
            $modifiedColumns[':p' . $index++]  = '`role_id`';
        }

        $sql = sprintf(
            'INSERT INTO `user_role` (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case '`user_id`':
                        $stmt->bindValue($identifier, $this->user_id, PDO::PARAM_INT);
                        break;
                    case '`role_id`':
                        $stmt->bindValue($identifier, $this->role_id, PDO::PARAM_INT);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
        }

        $this->setNew(false);
    }
272080
protected function fetch($template = '', $vars = [], $replace = [], $config = [])
    {
        // 页面标题
        $this->assign('site_title', $this->site_title);
        
        return $this->view->fetch($template, $vars, $replace, $config);
    }
48617
public static function write(SqlDataSource $ds, $mode, $args, $cb=NULL)
	{
		$args = (array) $args;		
		$sql = array_shift($args);// 缺省第一个参数是sql字符串
		
		$ds->execute($sql);
		
		switch ($mode)
		{			
			case self::MODE_WRITE_INSERT: // 插入操作可选 得到主键标识
				$id = array_shift($args);
				$result = $id ? $ds->insert_id() : $ds->affected_rows();
				break;
			case self::MODE_WRITE_UPDATE:
			case self::MODE_WRITE_DELETE:
				$result = $ds->affected_rows();
				break;
			default:
				throw new SqlError("invalid write mode: {$mode}");
		}
		
		return (empty($cb) || !is_callable($cb)) ? $result : call_user_func_array($cb,array($result));
	}
513249
public function query_db($pagesize, $useinitialsbar = true) {
        list($twhere, $tparams) = $this->get_sql_where();

        $total = user_get_total_participants($this->course->id, $this->currentgroup, $this->accesssince,
            $this->roleid, $this->enrolid, $this->status, $this->search, $twhere, $tparams);

        $this->pagesize($pagesize, $total);

        $sort = $this->get_sql_sort();
        if ($sort) {
            $sort = 'ORDER BY ' . $sort;
        }

        $rawdata = user_get_participants($this->course->id, $this->currentgroup, $this->accesssince,
            $this->roleid, $this->enrolid, $this->status, $this->search, $twhere, $tparams, $sort, $this->get_page_start(),
            $this->get_page_size());
        $this->rawdata = [];
        foreach ($rawdata as $user) {
            $this->rawdata[$user->id] = $user;
        }
        $rawdata->close();

        if ($this->rawdata) {
            $this->allroleassignments = get_users_roles($this->context, array_keys($this->rawdata),
                    true, 'c.contextlevel DESC, r.sortorder ASC');
        } else {
            $this->allroleassignments = [];
        }

        // Set initial bars.
        if ($useinitialsbar) {
            $this->initialbars(true);
        }
    }
118300
public function paginate($listRows = null, $simple = false, $config = [])
    {
        if (is_int($simple)) {
            $total  = $simple;
            $simple = false;
        }

        $paginate = Db::getConfig('paginate');

        if (is_array($listRows)) {
            $config   = array_merge($paginate, $listRows);
            $listRows = $config['list_rows'];
        } else {
            $config   = array_merge($paginate, $config);
            $listRows = $listRows ?: $config['list_rows'];
        }

        /** @var Paginator $class */
        $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\paginator\\driver\\' . ucwords($config['type']);
        $page  = isset($config['page']) ? (int) $config['page'] : call_user_func([
            $class,
            'getCurrentPage',
        ], $config['var_page']);

        $page = $page < 1 ? 1 : $page;

        $config['path'] = isset($config['path']) ? $config['path'] : call_user_func([$class, 'getCurrentPath']);

        if (!isset($total) && !$simple) {
            $options = $this->getOptions();

            unset($this->options['order'], $this->options['limit'], $this->options['page'], $this->options['field']);

            $bind    = $this->bind;
            $total   = $this->count();
            $results = $this->options($options)->bind($bind)->page($page, $listRows)->select();
        } elseif ($simple) {
            $results = $this->limit(($page - 1) * $listRows, $listRows + 1)->select();
            $total   = null;
        } else {
            $results = $this->page($page, $listRows)->select();
        }

        $this->removeOption('limit');
        $this->removeOption('page');

        return $class::make($results, $listRows, $page, $total, $simple, $config);
    }
1190122
public static function CreatePagerData ($total_count, $current_page, $limit, $options) {
		//==============================================
		//件数が0件の場合は空配列を返す
		//==============================================
		if ($total_count == 0) {
			return [];
		}

		//==============================================
		//オプションの取得と展開
		//==============================================
		$in_list_position	= $options['in_list_position'] ?? 3;
		$max_link_disp		= $options['max_link_disp'] ?? 5;

		//==============================================
		//ページ数の構成
		//==============================================
		//最大ページ数算出
		$max_page = static::GetMaxPage($total_count, $limit);

		//念のための検証
		if ($current_page < 1) {
			CoreException::RaiseSystemError('最小ページ数以下のページ番号を指定されました。page:%d', [$current_page]);
		}

		if ($max_page < $current_page) {
			CoreException::RaiseSystemError('最大ページ数以上のページ番号を指定されました。page:%d, max_page:%s', [$current_page, $max_page]);
		}

		//リンクリスト用ページ番号の構築
		//開始位置
		if ($current_page < $in_list_position) {
			$link_start_page	= 1;
		} else {
			$link_start_page	= $current_page - ceil($in_list_position / 2);
			if ($link_start_page + $max_link_disp >= $max_page) {
				$link_start_page	= $max_page - $max_link_disp + 1;
			}
		}

		if ($link_start_page < 1) {
			$link_start_page = 1;
		}

		//終了位置
		$link_end_page = $link_start_page + $max_link_disp - 1;
		if ($link_end_page > $max_page) {
			$link_end_page = $max_page;
		}

		//ページ数構成
		$page	= [
			'start'		=> 1,
			'end'		=> $max_page,
			'current'	=> $current_page,
			'next'		=> ($current_page < $max_page) ? $current_page + 1 : null,
			'previous'	=> ($current_page > 1) ? $current_page - 1 : null,
			'list'		=> range($link_start_page, $link_end_page),
			'round'		=> [
				'start'		=> $link_start_page > 1,
				'end'		=> $link_end_page < $max_page,
			],
			'is_first'		=> $current_page == 1,
			'is_last'		=> $current_page == $max_page,
			'enable'		=> $total_count > $limit,
		];

		//==============================================
		//件数の構成
		//==============================================
		//件数の構成
		$count	= [
			'total'		=> $total_count,
			'start'		=> ($max_page == 1) ? 1 : ($current_page - 1) * $limit + 1,
			'end'		=> ($max_page == $current_page) ? $total_count : $current_page * $limit
		];

		//==============================================
		//結果の返却
		//==============================================
		return compact('page', 'count');
	}
559809
public function updateNode($con, $insertId, $tableName = null)
    {
        $this->validate(['con' => $con, 'tableName' => $tableName, 'insertId' => $insertId]);
        
        if ($this->queryChanged) {
            $query = $this->selectQuery." WHERE ".$this->idColumn." = ". $insertId;
        } else {
            $query = $this->selectQuery.$tableName." WHERE ".$this->idColumn." = ". $insertId;
        }
        
        $data = $this->con->getData($con, $query);
        
        $params = [
            'index' => $this->client->getIndex(),
            'type'  => $this->client->getType(),
            'id'    => $data[0][$this->idColumn],
            'body'  => ['doc' => $data[0]]
        ];
        
        $responses = $this->client->getClient()->update($params);
        return $responses['result'];
    }
1209013
public static function retrieveByPK($user_id, $role_id, PropelPDO $con = null) {
        $_instancePoolKey = serialize(array((string) $user_id, (string) $role_id));
         if (null !== ($obj = UserRolePeer::getInstanceFromPool($_instancePoolKey))) {
             return $obj;
        }

        if ($con === null) {
            $con = Propel::getConnection(UserRolePeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $criteria = new Criteria(UserRolePeer::DATABASE_NAME);
        $criteria->add(UserRolePeer::USER_ID, $user_id);
        $criteria->add(UserRolePeer::ROLE_ID, $role_id);
        $v = UserRolePeer::doSelect($criteria, $con);

        return !empty($v) ? $v[0] : null;
    }
607218
public String convertToPageSql(String sql, Integer offset, Integer limit) {
        //解析SQL
        Statement stmt;
        try {
            stmt = CCJSqlParserUtil.parse(sql);
        } catch (Throwable e) {
            throw new PageException("不支持该SQL转换为分页查询!", e);
        }
        if (!(stmt instanceof Select)) {
            throw new PageException("分页语句必须是Select查询!");
        }
        //获取分页查询的select
        Select pageSelect = getPageSelect((Select) stmt);
        String pageSql = pageSelect.toString();
        //缓存移到外面了，所以不替换参数
        if (offset != null) {
            pageSql = pageSql.replace(START_ROW, String.valueOf(offset));
        }
        if (limit != null) {
            pageSql = pageSql.replace(PAGE_SIZE, String.valueOf(limit));
        }
        return pageSql;
    }
574233
public function selectPageEx($page = 1,$show = 10,&$recordCount = null)
	{
		if($this->isSelectBefore)
		{
			$this->__selectBefore();
		}
		$option = $this->operationOption;
		if(null === $recordCount)
		{
			if('Mysql' === $this->db->getType())
			{
				$isMysqlCount = true;
			}
			else
			{
				// 去除排序，提高效率
				if(isset($this->operationOption['order']))
				{
					unset($this->operationOption['order']);
				}
				$recordCount = $this->count();
				$this->operationOption = $option;
			}
		}
		if(isset($isMysqlCount) && $isMysqlCount)
		{
			$this->operationOption['fieldBefore'] = array('SQL_CALC_FOUND_ROWS');
		}
		$this->operationOption['field'] = array($this->tableName() . '.' . $this->pk);
		$this->db->operationOption = $this->page($page,$show)->getOption();
		$pks = $this->db->queryColumn();
		if(!isset($pks[0]))
		{
			return array();
		}
		if(isset($isMysqlCount) && $isMysqlCount)
		{
			$recordCount = $this->db->getScalar('select FOUND_ROWS()');
		}
		$this->operationOption = $option;
		$this->operationOption['where'] = array(
			array($this->tableName() . '.' . $this->pk => array('in', $pks))
		);
		$this->db->operationOption = $this->getOption();
		$data = $this->db->query();
		$this->__selectAfter($data,$option);
		return $data;
	}
1303999
protected function parseLike(Query $query, $key, $exp, $value, $field, $bindType, $logic)
    {
        // 模糊匹配
        if (is_array($value)) {
            foreach ($value as $item) {
                $name    = $query->bind($item, $bindType);
                $array[] = $key . ' ' . $exp . ' :' . $name;
            }

            $whereStr = '(' . implode($array, ' ' . strtoupper($logic) . ' ') . ')';
        } else {
            $whereStr = $key . ' ' . $exp . ' ' . $value;
        }

        return $whereStr;
    }
514511
public function _loadConfigVars(Smarty_Internal_Template $tpl, $_config_vars)
    {
        $this->_assignConfigVars($tpl->parent, $tpl, $_config_vars);
        $scope = $tpl->source->scope;
        if (!$scope && !$tpl->scope) {
            return;
        }
        foreach (array($scope, $tpl->scope) as $s) {
            $s = ($bubble_up = $s >= Smarty::SCOPE_BUBBLE_UP) ? $s - Smarty::SCOPE_BUBBLE_UP : $s;
            if ($bubble_up && $s) {
                $ptr = $tpl->parent->parent;
                if (isset($ptr)) {
                    $this->_assignConfigVars($ptr, $tpl, $_config_vars);
                    $ptr = $ptr->parent;
                }
                if ($s == Smarty::SCOPE_PARENT) {
                    continue;
                }
                while (isset($ptr) && $ptr->_objType == 2) {
                    $this->_assignConfigVars($ptr, $tpl, $_config_vars);
                    $ptr = $ptr->parent;
                }
                if ($s == Smarty::SCOPE_TPL_ROOT) {
                    continue;
                } elseif ($s == Smarty::SCOPE_SMARTY) {
                    $this->_assignConfigVars($tpl->smarty, $tpl, $_config_vars);
                } elseif ($s == Smarty::SCOPE_GLOBAL) {
                    $this->_assignConfigVars($tpl->smarty, $tpl, $_config_vars);
                } elseif ($s == Smarty::SCOPE_ROOT) {
                    while (isset($ptr->parent)) {
                        $ptr = $ptr->parent;
                    }
                    $this->_assignConfigVars($ptr, $tpl, $_config_vars);
                }
            }
        }
    }
492318
protected function doInsert(PropelPDO $con)
    {
        $modifiedColumns = array();
        $index = 0;

        $this->modifiedColumns[] = CustomerPeer::ID;
        if (null !== $this->id) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . CustomerPeer::ID . ')');
        }

         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(CustomerPeer::ID)) {
            $modifiedColumns[':p' . $index++]  = '`id`';
        }
        if ($this->isColumnModified(CustomerPeer::NAME)) {
            $modifiedColumns[':p' . $index++]  = '`name`';
        }
        if ($this->isColumnModified(CustomerPeer::STREET)) {
            $modifiedColumns[':p' . $index++]  = '`street`';
        }
        if ($this->isColumnModified(CustomerPeer::ZIP)) {
            $modifiedColumns[':p' . $index++]  = '`zip`';
        }
        if ($this->isColumnModified(CustomerPeer::CITY)) {
            $modifiedColumns[':p' . $index++]  = '`city`';
        }
        if ($this->isColumnModified(CustomerPeer::COUNTRY_ID)) {
            $modifiedColumns[':p' . $index++]  = '`country_id`';
        }
        if ($this->isColumnModified(CustomerPeer::PHONE)) {
            $modifiedColumns[':p' . $index++]  = '`phone`';
        }
        if ($this->isColumnModified(CustomerPeer::FAX)) {
            $modifiedColumns[':p' . $index++]  = '`fax`';
        }
        if ($this->isColumnModified(CustomerPeer::EMAIL)) {
            $modifiedColumns[':p' . $index++]  = '`email`';
        }
        if ($this->isColumnModified(CustomerPeer::LEGALFORM)) {
            $modifiedColumns[':p' . $index++]  = '`legalform`';
        }
        if ($this->isColumnModified(CustomerPeer::LOGO)) {
            $modifiedColumns[':p' . $index++]  = '`logo`';
        }
        if ($this->isColumnModified(CustomerPeer::CREATED)) {
            $modifiedColumns[':p' . $index++]  = '`created`';
        }
        if ($this->isColumnModified(CustomerPeer::NOTES)) {
            $modifiedColumns[':p' . $index++]  = '`notes`';
        }

        $sql = sprintf(
            'INSERT INTO `customer` (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case '`id`':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case '`name`':
                        $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
                        break;
                    case '`street`':
                        $stmt->bindValue($identifier, $this->street, PDO::PARAM_STR);
                        break;
                    case '`zip`':
                        $stmt->bindValue($identifier, $this->zip, PDO::PARAM_STR);
                        break;
                    case '`city`':
                        $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR);
                        break;
                    case '`country_id`':
                        $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT);
                        break;
                    case '`phone`':
                        $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR);
                        break;
                    case '`fax`':
                        $stmt->bindValue($identifier, $this->fax, PDO::PARAM_STR);
                        break;
                    case '`email`':
                        $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR);
                        break;
                    case '`legalform`':
                        $stmt->bindValue($identifier, $this->legalform, PDO::PARAM_STR);
                        break;
                    case '`logo`':
                        $stmt->bindValue($identifier, $this->logo, PDO::PARAM_STR);
                        break;
                    case '`created`':
                        $stmt->bindValue($identifier, $this->created, PDO::PARAM_STR);
                        break;
                    case '`notes`':
                        $stmt->bindValue($identifier, $this->notes, PDO::PARAM_STR);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
        }

        try {
            $pk = $con->lastInsertId();
        } catch (Exception $e) {
            throw new PropelException('Unable to get autoincrement id.', $e);
        }
        $this->setId($pk);

        $this->setNew(false);
    }
640109
private function GetPostParams($Source, $ParamList, $MergeParams = [])
        {
            // 過濾非法參數
            $PostParams = [];
            foreach ($ParamList as $Name => $Value) {
                if (isset($Source[$Name])) {
                    $PostParams[$Name] = $Source[$Name];
                } else {
                    // 若未設定則帶預設值
                    $PostParams[$Name] = $Value;
                }
            }

            return array_merge($MergeParams, $PostParams);
        }