设置表名，使用SQL原生语句
@param string $raw
@return static
359632
public function tableRaw(string $raw)
    {
        $this->option->table->useRaw(true);
        $this->option->table->setRawSQL($raw);
        return $this;
    }
276790
public function joinRaw($table, $raw, $type = 'inner')
	{
		$this->syntax->setRawJoin($table, $raw, $type);
		return $this;
	}
1178301
public static function raw($sql) {
	$exception = bootstrap::get_library('exception');
	$response  = bootstrap::get_library('response');
	
	if (is_null(self::$connection)) {
		throw new $exception('no db connection', $response::STATUS_SERVICE_UNAVAILABLE);
	}
	
	$result = self::$connection->query($sql);
	
	self::$error_number  = self::$connection->errno;
	self::$error_message = self::$connection->error;
	if (self::$error_number) {
		throw new $exception(self::$error_message, self::$error_number);
	}
	
	if ($result instanceof \mysqli_result) {
		self::$num_rows = $result->num_rows;
	}
	self::$insert_id     = self::$connection->insert_id;
	self::$affected_rows = self::$connection->affected_rows;
	
	return $result;
}
360295
public function prepare($sql, $link = null, $resetParams = true)
    {
        $resetParams && $this->reset();
        is_null($link) && $link = $this->currentQueryIsMaster ? $this->wlink : $this->rlink;

        $sqlParams = [];
        foreach ($this->bindParams as $key => $val) {
            $sqlParams[] = ':param' . $key;
        }

        $this->currentSql = $sql;
        $sql = vsprintf($sql, $sqlParams);

        $stmt = $link->prepare($sql);//pdo默认情况prepare出错不抛出异常只返回Pdo::errorInfo
        if ($stmt === false) {
            $error = $link->errorInfo();
            if (in_array($error[1], [2006, 2013])) {
                $link = $this->connectDb($this->currentQueryIsMaster ? 'wlink' : 'rlink', true);
                $stmt = $link->prepare($sql);
                if ($stmt === false) {
                    $error = $link->errorInfo();
                } else {
                    return $stmt;
                }
            }
            throw new \InvalidArgumentException(
                'Pdo Prepare Sql error! ,【Sql: ' . $this->buildDebugSql() . '】,【Code: ' . $link->errorCode() . '】, 【ErrorInfo!: 
                ' . $error[2] . '】 '
            );
        }
        return $stmt;
    }
1272446
public static function fromRaw(string $raw, string $format = null): string
    {
        $format = $format ?? self::$format;

        switch ($format) {
            case self::FORMAT_HEX:
                return \bin2hex($raw);

            case self::FORMAT_BASE64:
                return \base64_encode($raw);

            case self::FORMAT_STR:
                $field = \strtoupper(bin2hex($raw));
                $field = \chunk_split($field, 2, '\x');

                return '\x' . \substr($field, 0, -2);

            case self::FORMAT_RAW:
                return $raw;

            default:
                throw new InvalidArgumentException("Crypto return format not defined: $format");
        }
    }
422532
public static function insertBySql($sql)
    {
        if (is_array($sql)) {
            $bind = $sql;
            unset($bind[0]);
            $sql = $sql[0];
        } else {
            $bind = [];
        }

        $model = new static;

        $table = $model->getSource($bind);
        return $model->getConnection($bind)->insertBySql('INSERT' . " INTO [$table] " . $sql, $bind);
    }
247555
public function orderByRaw($sql, $bindings = array())
	{
		$type = 'raw';

		$this->orders[] = compact('type', 'sql');

		$this->bindings = array_merge($this->bindings, $bindings);

		return $this;
	}
463412
private function build($rawString) {
        $parseHelper = new ParseHelper();
        $rawString = trim($rawString);
        //Parse name
        if(preg_match('@`(?P<name>[^`]+)`@', $rawString, $matches)) {
            $this->setName($matches['name']);
            $rawString = substr($rawString, strlen($matches[0]));
        }

        $rawString = trim($rawString);
        $type = $parseHelper->parseSection($rawString);
        $this->setType($type);
        $rawString = substr($rawString, strlen($type));

        $rawString = trim($rawString);
        if(preg_match('@^unsigned($| )@', $rawString, $matches)) {
            $this->setUnsigned(true);
            $rawString = substr($rawString, strlen($matches[0]));
        }

        $rawString = trim($rawString);
        if(preg_match('@^COLLATE (?P<collate>[^ ]+)($| )@', $rawString, $matches)) {
            $this->setCollate($matches['collate']);
            $rawString = substr($rawString, strlen($matches[0]));
        }

        $rawString = trim($rawString);
        if(preg_match('@^(?P<nullable>NOT NULL|NULL)($| )@', $rawString, $matches)) {
            $this->setNullable($matches['nullable'] == 'NULL');
            $rawString = substr($rawString, strlen($matches[0]));
        }

        $rawString = trim($rawString);
        if(preg_match('@^AUTO_INCREMENT($| )@', $rawString, $matches)) {
            $this->setAutoIncrement(true);
            $rawString = substr($rawString, strlen($matches[0]));
        }

        $rawString = trim($rawString);
        if(preg_match('@^DEFAULT @', $rawString, $matches)) {
            $rawString = substr($rawString, strlen($matches[0]));
            $default = $parseHelper->parseSection($rawString);
            $this->setDefault($default);
            $rawString = substr($rawString, strlen($default));
        }
        $rawString = trim($rawString);
        if(preg_match('@^COMMENT @', $rawString, $matches)) {
            $rawString = substr($rawString, strlen($matches[0]));
            $comment = $parseHelper->parseSection($rawString);
            $this->setComment($comment);
            $rawString = substr($rawString, strlen($comment));
        }
    }
927782
public function orderRaw($raw)
    {
        if(is_array($raw))
        {
            foreach($raw as $k => $v)
            {
                if(is_numeric($k))
                {
                    $fieldName = $v;
                    $direction = 'asc';
                }
                else
                {
                    $fieldName = $k;
                    $direction = $v;
                }
                $this->option->order[] = new Order($fieldName, $direction);
            }
        }
        else
        {
            $order = new Order();
            $order->useRaw();
            $order->setRawSQL($raw);
            $this->option->order[] = $order;
        }
        return $this;
    }
1026244
public function compile($rawSQL, array $references)
    {
        foreach ($references as &$value) {
            $value = $this->convertReferenceToValue($value);
        }

        return $this->replace($rawSQL, $references);
    }
676841
public function get($raw = false) {
        return $raw 
                ? $this->_data
                : $this->_format($this->_data);
    }
807695
private function build($rawString) {
        $rawString = str_replace('`, `','`,`', $rawString);
        $onDelete = '( ON DELETE (?P<onDelete>NO ACTION|RESTRICT|CASCADE|SET NULL))?';
        $onUpdate = '( ON UPDATE (?P<onUpdate>NO ACTION|RESTRICT|CASCADE|SET NULL))?';
        if(preg_match(
            '@^CONSTRAINT `(?P<name>[^`]+)` FOREIGN KEY \((?P<localColumns>[^\)]+)\) REFERENCES `(?P<remoteTable>[^`]+)` \((?P<remoteColumns>[^\)]+)\)' . $onDelete . $onUpdate . '$@',
            $rawString,
            $matches
        )) {
            $this->setName($matches['name']);
            $this->setLocalColumns(explode('`,`', trim($matches['localColumns'], '`')));
            $this->setRemoteTable($matches['remoteTable']);
            $this->setRemoteColumns(explode('`,`', trim($matches['remoteColumns'], '`')));
            if(isset($matches['onDelete'])) {
                $this->setDeleteAction($matches['onDelete']);
            }
            if(isset($matches['onUpdate'])) {
                $this->setUpdateAction($matches['onUpdate']);
            }
        }
    }
600732
public function create($db = '')
    {
        $dbConfig = Db::getConfig();
        $prefix = $db == ''? $dbConfig['prefix'] : $dbConfig[$db]['prefix'];

        if (file_exists($this->_lockFile)) {
            echo "<b style='color:red'>数据库创建操作被锁定，请删除[{$this->_lockFile}]文件后重试</b>";
            exit;
        }

        if ($this->_generateSql($prefix) === false) {
            echo '执行sql语句出错，请检查配置';
            exit;
        }
        echo '执行成功,如非必要请不要解锁后再次执行，重复执行会清空原有rbac表中的数据';
        $this->_writeLock();
        exit;
    }
1325139
protected function prepare_form_fields(array $raw) {

        $formdata = new stdclass();
        $key = 0;
        foreach ($raw as $dimension) {
            $formdata->{'dimensionid__idx_' . $key}             = $dimension->id;
            $formdata->{'description__idx_' . $key}             = $dimension->description;
            $formdata->{'description__idx_' . $key.'format'}    = $dimension->descriptionformat;
            $key++;
        }
        return $formdata;
    }
528625
public function executeRaw($sql) {
        if (!is_string($sql)) throw new IllegalTypeException('Illegal type of parameter $sql: '.gettype($sql));
        if (!$this->isConnected())
            $this->connect();

        // execute statement
        $result = null;
        try {
            $result = pg_query($this->hConnection, $sql);         // wraps multi-statement queries in a transaction
            !$result && trigger_error(pg_last_error($this->hConnection), E_USER_ERROR);
        }
        catch (\Exception $ex) {
            if (!$ex instanceof IRosasurferException)
                $ex = new DatabaseException($ex->getMessage(), $ex->getCode(), $ex);
            throw $ex->addMessage('Database: '.$this->getConnectionDescription().NL.'SQL: "'.$sql.'"');
        }

        $status_string = pg_result_status($result, PGSQL_STATUS_STRING);

        // reset last_insert_id on INSERTs, afterwards it's resolved on request as it requires an extra SQL query
        if (strStartsWithI($status_string, 'INSERT '))
            $this->lastInsertId = null;

        // track last_affected_rows
        $pattern = '/^(INSERT|UPDATE|DELETE)\b/i';
        if (preg_match($pattern, $status_string))
            $this->lastAffectedRows = pg_affected_rows($result);

        return $result;

    }
901875
public static function input($prompt = null, $raw = false)
    {
        if (isset($prompt)) {
            static::stdout($prompt);
        }
        return static::stdin($raw);
    }
1115114
public function rawSelectAll()
        {
            $query = new Query($this);
            $query->generateSelectSQL(true);

            return Statement::getPreparedStatement($query)->execute();
        }