获取执行语句中的涉及表名
@param string $sql 语句
@return array 表名列表
356595
public function getNameFromExecute(string $sql): array
    {
        $matches = null;

        // 获取命令字
        if (!preg_match('/^(\w+)\b/i', $sql, $matches)) {
            trigger_error('SQL语句格式错误:' . $sql, E_USER_ERROR);
        }

        // 只支持Insert,Update,Delete,Replace语句,其它不支持
        $command = strtolower($matches[0]);
        if (!in_array($command, ['insert', 'update', 'delete', 'replace'])) {
            trigger_error('执行命令无法识别或不支持:' . $command, E_USER_ERROR);
        }

        // 匹配表名部分,包括 insert [into] $tbl , replace [into] $tbl, update $tbl, delete from $tbl
        if (!preg_match_all('/insert\s+(into\s+)?([\w|`]+)|replace\s+(into\s+)?([\w|`]+)|delete\s+from\s+([\w|`]+)|update\s+([\w|`]+)/i', $sql, $matches)) {
            trigger_error('无法识别执行命令中的表名:' . $sql, E_USER_ERROR);
        }

        // 收集匹配的表名
        $names = [];

        // 匹配项中的第2,4,5,6项
        foreach ([2, 4, 5, 6] as $i) {
            // 每一项都是数组
            foreach ($matches[$i] as $name) {
                // 如果有匹配,去定界符,加入到表名列表中
                if ($name) {
                    array_push($names, trim($name, '`'));
                }
            }
        }
        return $names;
    }
617733
public static function getAll($sql)
    {
        try {
            // return self::$conn->query($sql, PDO::FETCH_ASSOC);
            
            $stmt = self::$conn->prepare($sql);
            $stmt->execute();
            
            // set the resulting array to associative
            $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
            return $result;
        } catch (PDOException $e) {
            echo '<br><span style="color:red;">Line #' . __LINE__ . ' (/X.php) </span> ' . $sql . "</hr>" . $e->getMessage();
        }
    }
811619
public static function preparedQuery($sql) {
        self::init();
        if(!empty($exclusions = self::$_ops->getExclusions())) {
            $prepared = self::prepareStmt($sql);
            $inserts = [];
            $types = '';
            foreach($exclusions as $i => $substitute) {
                $types .= $substitute['type'];
                $inserts[] = $substitute['value'];
            }
            return self::executeStmt($prepared, $types, $inserts);
        } else {
            return self::query($sql);
        }
    }
130513
public final function query($sql)
    {
        if ($this->debug)
        {
            echo "$sql<br />\n<hr />";
        }
        $res = parent::query($sql) or \Swoole\Error::info(
            "SQL Error",
            implode(", ", $this->errorInfo()) . "<hr />$sql"
        );
        $this->lastStatement = $res;
        //非查询语句直接返回结果
        if ($sql[0] !== 's')
        {
            return !empty($res);
        }
        return $res;
    }
764472
protected function prepareExpressionPlaceholders($sql)
    {
        if (!count($this->expressions)) {
            return $sql;
        }
        $sql = str_replace(array_keys($this->expressions), array_values($this->expressions), $sql);

        return $sql;
    }
1221076
protected function query_one ( $sql )
	{
		$sql = $this->sql_printf(func_get_args());
		if (!($res = mysqli_query( $this->conn, $sql)))
		{
			$this->sql_errcheck($sql);
		}
		if ($row = mysqli_fetch_assoc($res))
		{
			$val = array_pop($row);
		}
		else
		{
			$val = false;
		}
		((mysqli_free_result($res) || (is_object($res) && (get_class($res) == "mysqli_result"))) ? true : false);
		return $val;
	}
120995
protected function getJoinSql(array $sql): array
    {
        if (empty($this->join)) {
            return $sql;
        }
        foreach ($this->join as $item) {
            [$type, $table, $leftField, $operator, $rightField] = $item;
            $joinType = strtoupper($type) . ' JOIN';
            $table = $this->quoter->quoteName($table);
            if ($leftField instanceof RawExp) {
                $sql[] = sprintf('%s %s ON (%s)', $joinType, $table, $leftField->getValue());
            } else {
                $leftField = $this->quoter->quoteName($leftField);
                $rightField = $this->quoter->quoteName($rightField);
                $sql[] = sprintf('%s %s ON %s %s %s', $joinType, $table, $leftField, $operator, $rightField);
            }
        }

        return $sql;
    }
70505
public function getArray($sql = null, $parameters = array()) {
		$this->execute($sql);
		$result = array();
		while (!!$objs = mysqli_fetch_assoc($this->result) ) {
			$result[] = $objs;
		}
		return $result;
	}
266547
public function selectValues($sql)
    {
        $result = $this->execute($sql);
        if ($result->count()) {
            $values = [];
            foreach ($result as $row) {
                $values[] = reset($row);
            }
            return $values;
        }
    }
160246
public function getArray($sql, $parameters = array()) {
        $this->execute($sql);
        $result = array();
        while (!!$objs = mysql_fetch_assoc($this->result) ) {
            $result[] = $objs;
        }
        return $result;
    }
522832
protected function query_row ( $sql )
	{
		$sql = $this->sql_printf(func_get_args());
		if (!($res = mysqli_query( $this->conn, $sql)))
		{
			$this->sql_errcheck($sql);
		}
		if ($row = mysqli_fetch_array($res))
		{
			$rs = $row;
		}
		else
		{
			$rs = false;
		}
		((mysqli_free_result($res) || (is_object($res) && (get_class($res) == "mysqli_result"))) ? true : false);
		return $rs;
	}
1048765
private function parseFloatParams($sql)
    {
        foreach ($this->floatParams as $name => $value) {
            if (strncmp($name, ':', 1) !== 0) {
                $name = ':' . $name;
            }
            // unable to use `str_replace()` because particular param name may be a substring of another param name
            $sql = preg_replace('/' . preg_quote($name) . '\b/s', $value, $sql);
        };

        return $sql;
    }
1029871
private function _parseSql($sql)
    {
        return array_values(array_filter(array_map(function ($value) { return trim(rtrim($value, $this->separator)); },
            preg_split(sprintf("/%s[\s]*\n/", preg_quote($this->separator)), rtrim(trim($sql), $this->separator)))));
    }
868904
protected function fix_table_names($sql) {
        if (preg_match_all('/\{([a-z][a-z0-9_]*)\}/i', $sql, $matches)) {
            foreach ($matches[0] as $key => $match) {
                $name = $matches[1][$key];

                if ($this->temptables->is_temptable($name)) {
                    $sql = str_replace($match, $this->temptables->get_correct_name($name), $sql);
                } else {
                    $sql = str_replace($match, $this->prefix.$name, $sql);
                }
            }
        }
        return $sql;
    }
1245019
final protected function executeQuery($sql)
    {
        $statement = $this->connection->prepare($sql);
        $statement->execute();
        return $statement->fetchAll();
    }
975272
public function parseSqlTable($sql)
    {
        if (false !== strpos($sql, '__')) {
            $prefix = $this->prefix;
            $sql    = preg_replace_callback("/__([A-Z0-9_-]+)__/sU", function ($match) use ($prefix) {
                return $prefix . strtolower($match[1]);
            }, $sql);
        }
        return $sql;
    }
799918
protected function getAliasSql(string $sql): string
    {
        if (!isset($this->alias)) {
            return $sql;
        }

        return sprintf('(%s) AS %s', $sql, $this->quoter->quoteName($this->alias));
    }