Retrieves unprocessed table names used in a query (excluding subqueries).

@param Query $query
@return string[]
342354
protected function getTables(Query $query): array
    {
        $tables = [];

        if (is_string($query->table)) {
            $tables[] = $query->table;
        }

        foreach ($query->join as $join) {
            if (is_string($join->table)) {
                $tables[] = $join->table;
            }
        }

        return $tables;
    }
1159848
protected function parseData(Query $query, $data)
    {
        if (empty($data)) {
            return [];
        }

        $result = [];

        foreach ($data as $key => $val) {
            $item = $this->parseKey($key);

            if (is_object($val)) {
                $result[$item] = $val;
            } elseif (isset($val[0]) && 'exp' === $val[0]) {
                $result[$item] = $val[1];
            } elseif (is_null($val)) {
                $result[$item] = 'NULL';
            } else {
                $result[$item] = $this->parseValue($query, $val, $key);
            }
        }

        return $result;
    }
60989
protected function parseTable(Query $query, $tables)
    {
        $item    = [];
        $options = $query->getOptions();

        foreach ((array) $tables as $key => $table) {
            if (!is_numeric($key)) {
                $key    = $this->connection->parseSqlTable($key);
                $item[] = $this->parseKey($query, $key) . ' ' . $this->parseKey($query, $table);
            } else {
                $table = $this->connection->parseSqlTable($table);

                if (isset($options['alias'][$table])) {
                    $item[] = $this->parseKey($query, $table) . ' ' . $this->parseKey($query, $options['alias'][$table]);
                } else {
                    $item[] = $this->parseKey($query, $table);
                }
            }
        }

        return implode(',', $item);
    }
413071
final public function queryArray(string $query)
    {
        $result = $this->queryResult($query);
        if (false === $result) {
            return false;
        }

        $return = [];
        while (false !== $row = $result->fetchRow()) {
            $return[] = $row;
        }
        return $return;
    }
1161232
private function parseQueryError(string $query): array
    {
        $return = ['sql_state' => null, 'code' => null, 'message' => 'Unknown error.'];
        $resource = $this->resource->getObject();

        if (isset($resource->error_list[0])) {
            [$errno, $sqlstate, $error] = array_values($resource->error_list[0]);
        } else {
            [$errno, $sqlstate, $error] = [$resource->errno, $resource->sqlstate, $resource->error];
        }

        if ($errno) {
            $return['sql_state'] = $sqlstate;
            $return['code'] = $errno;
            // dump useless verbose message
            if ($errno == 1064) {
                preg_match('~syntax to use near (?<query>.+) at line (?<line>\d+)~sm', $error, $match);
                if (isset($match['query'], $match['line'])) {
                    $return['message'] = sprintf('Syntax error at or near "%s", line %d. Query: "%s".',
                        trim(substr($match['query'], 1, (int) ceil(strlen($match['query']) / 2))), $match['line'], $query);
                } else {
                    $return['message'] = $error;
                }
            } else {
                $return['message'] = $error;
            }
        }

        return $return;
    }
375121
public function process(Query $query, $rows)
    {
        $meta = [
            'hasPrevious' => false,
            'previousCursor' => null,
            'hasNext' => false,
            'nextCursor' => null,
        ];

        if ($this->shouldLtrim($query, $rows)) {
            $type = $query->direction()->forward() ? 'previous' : 'next';
            $meta['has' . ucfirst($type)] = true;
            $meta[$type . 'Cursor'] = $this->makeCursor(
                $query,
                $this->offset($rows, (int)$query->exclusive())
            );
            $rows = $this->slice($rows, 1);
        }
        if ($this->shouldRtrim($query, $rows)) {
            $type = $query->direction()->backward() ? 'previous' : 'next';
            $meta['has' . ucfirst($type)] = true;
            $meta[$type . 'Cursor'] = $this->makeCursor(
                $query,
                $this->offset($rows, $query->limit() - $query->exclusive())
            );
            $rows = $this->slice($rows, 0, $query->limit());
        }

        // If we are not using UNION ALL, boolean values are not defined.
        if (!$query->selectOrUnionAll() instanceof UnionAll) {
            $meta[$query->direction()->forward() ? 'hasPrevious' : 'hasNext'] = null;
        }

        return $this->invokeFormatter($this->shouldReverse($query) ? $this->reverse($rows) : $rows, $meta, $query);
    }
36890
protected function checkQuery($query=null)
    {
        if ($query) {
            $this->getQuery()->set($query);
            unset($query);
        }
        
        $query = $this->getQuery();
        
        // if no table then set table
        if (!isset($query['table'])) {
            $query['table'] = $this->getTableName();
        }
        
        // use model database.table_prefix
        if (!isset($query['database']) && isset($this['database'])) {
            $query['database'] = $this['database'];
        }
        
        if (!isset($query['table_prefix']) && isset($this['table_prefix'])) {
            $query['table_prefix'] = $this['table_prefix'];
        }
        
        return static::formatQuery($query);
    }
79261
public function getResults($query)
    {
        $parameters = [];

        if (is_object($query) && $query instanceof SearchQuery) {
            $query = $query->toArray();
        }

        if (is_array($query)) {
            $collection = new Collection($query);

            $query = $collection->pull('query', '');

            $parameters = $collection->toArray();
        }

        return $this->index->search($query, $parameters);
    }
437539
public function findWith(QueryBuilder $query)
    {
        $this->load($query);

        $result = $query->execute()->fetchAll();
        if ($result) {
            return $this->hydrateAll($result, $query);
        }

        return [];
    }
562853
public function buildDelete(Query $query) {
        return $this->renderStatement(Query::DELETE, [
            'table' => $this->formatTable($query->getTable(), $query->getAlias()),
            'joins' => $this->formatJoins($query->getJoins()),
            'where' => $this->formatWhere($query->getWhere()),
            'orderBy' => $this->formatOrderBy($query->getOrderBy()),
            'limit' => $this->formatLimit($query->getLimit()),
        ] + $this->formatAttributes($query->getAttributes()));
    }
646436
private static function parseQuery( $query )
   {

      if ( empty( $query ) )
      {
         return [];
      }

      $elements = [];

      \parse_str( $query, $elements );

      if ( ! \is_array( $elements ) )
      {
         return [];
      }

      return $elements;

   }
997311
private function parseQueryError(string $query): array
    {
        $return = ['sql_state' => null, 'code' => null, 'message' => 'Unknown error.'];
        if ($error = error_get_last()) {
            $error = explode("\n", $error['message']);
            // search for sql state
            preg_match('~ERROR:\s+(?<sql_state>[0-9A-Z]+?):\s+(?<message>.+)~', $error[0], $match);
            if (isset($match['sql_state'], $match['message'])) {
                $return['sql_state'] = $match['sql_state'];
                // line & query details etc.
                if (count($error) == 3 && preg_match('~(LINE\s+(?<line>\d+):\s+).+~', $error[1], $match2)) {
                    $return['message'] = sprintf('%s, line %d. Query: "%s".', ucfirst($match['message']),
                        $match2['line'], $query);
                } else {
                    $return['message'] = $match['message'] .'.';
                }
            }
        }

        return $return;
    }
1090401
public static function executeRows(string $query): array
  {
    self::logQuery($query);

    return self::$dl->executeRows($query);
  }
1214363
private function getQueryFields() : array
    {
        $result = [];
        foreach ($this->criteria as $criteria) {
            $field = $this->table->aliasField($criteria->getField());
            if (! in_array($field, $result)) {
                $result[] = $field;
            }
        }

        foreach ($this->query->clause('select') as $field) {
            if (is_string($field) && ! in_array($field, $result)) {
                $result[] = $field;
            }
        }

        return $result;
    }
191354
protected function load(Select $query) : array
    {
        $rows = $this->connection->load($query);

        return $this->mapper->loadAll($this->loadingContext, $rows->getRows());
    }
988593
public static function getAll($query)
    {
        $ret = array();

        $res = self::query($query);
        if ($res) {
            while ($row = self::connection()->sql_fetch_assoc($res)) {
                $ret[] = $row;
            }
            self::free($res);
        }

        return $ret;
    }
688257
public function resolveParams(Query $query) {
        $params = [];
        $schema = $query->getRepository()->getSchema()->getColumns();

        foreach ($query->getGroupedBindings() as $groupedBinds) {
            foreach ($groupedBinds as $binds) {
                $params[] = $this->resolveBind($binds['field'], $binds['value'], $schema);
            }
        }

        foreach ($query->getCompounds() as $compound) {
            $params = array_merge($params, $this->resolveParams($compound));
        }

        return $params;
    }