Query for showing all tables

@param string|null $like The like pattern

@return QueryUtility
540753
public function showTables($like = null)
    {
        $like = $like ? ' LIKE '.$like : null;
        $this->query = 'SHOW TABLES'.$like;
        return $this;
    }
955455
public function listTables($pattern = '/.*/')
    {
        $tables                 = [];
        $lastEvaluatedTableName = null;
        do {
            $args = [
                "Limit" => 30,
            ];
            if ($lastEvaluatedTableName) {
                $args['ExclusiveStartTableName'] = $lastEvaluatedTableName;
            }
            $cmd    = $this->db->getCommand(
                'ListTables',
                $args
            );
            $result = $this->db->execute($cmd);
            if (isset($result['LastEvaluatedTableName'])) {
                $lastEvaluatedTableName = $result['LastEvaluatedTableName'];
            }
            else {
                $lastEvaluatedTableName = null;
            }
            
            foreach ($result['TableNames'] as $tableName) {
                if (preg_match($pattern, $tableName)) {
                    $tables[] = $tableName;
                }
            }
        } while ($lastEvaluatedTableName != null);
        
        return $tables;
    }
1075169
public function showTables()
    {
        $sql = 'SHOW TABLES';
        $query = $this->pdo->prepare($sql);
        $query->execute();

        return $query->fetchAll(PDO::FETCH_ASSOC);
    }
806140
public function getQuery(): Query
    {
    	// TODO: Bindings could be defined only locally in this method because it has to be regenerated on every call

        if (count($this->from) == 0) {
            throw new Exception('Can not build SELECT query, there is no FROM table defined');
        }

        $query = "SELECT\n";

        if (sizeof($this->fields) == 0) {
            $query .= "\t*";
        } else {
            foreach ($this->fields as $fld) {
                $field = $fld['name'];
                $as = $fld['as'];

                $query .= "\t{$field}";
                if ($as !== null) {
                    $query .= " as {$as}";
                }

                $query .= ",\n";
            }

            $query = substr($query, 0, -2);
        }

        $query .= "\nFROM";
        foreach ($this->from as $from) {
            if ($from['table'] instanceof static) {
                /* @var $subSelect \Koldy\Db\Query\Select */
                $subSelect = $from['table'];
                $subSql = $subSelect->__toString();
                $subSql = str_replace("\n", "\n\t", $subSql);
                $query .= " (\n\t{$subSql}\n) {$from['alias']}\n";

                $subSelectBindings = $subSelect->getBindings();
                if (!$subSelectBindings->isEmpty()) {
                    $this->getBindings()->addBindingsFromInstance($subSelectBindings);
                }
            } else {
                $query .= "\n\t{$from['table']}";
                if ($from['alias'] !== null) {
                    $query .= " as {$from['alias']},";
                } else {
                    $query .= ',';
                }
            }
        }
        $query = substr($query, 0, -1);

        foreach ($this->joins as $join) {
            $query .= "\n\t{$join['type']} {$join['table']} ON ";

            if (is_array($join['first'])) {
                foreach ($join['first'] as $joinArg) {
                    if ($joinArg instanceof Expr) {
                        $query .= "{$joinArg} AND ";

                    } else if (is_array($joinArg) && count($joinArg) == 2) {
                        $query .= "{$joinArg[0]} = {$joinArg[1]} AND ";

                    } else if (is_array($joinArg) && count($joinArg) == 3) {
                        $query .= "{$joinArg[0]} {$joinArg[1]} {$joinArg[2]} AND ";

                    } else if (is_array($joinArg) && count($joinArg) == 4) {
                        if (substr($query, -5) == ' AND ') {
                            $query = substr($query, 0, -5);
                        }

                        $query .= " {$joinArg[0]} {$joinArg[1]} {$joinArg[2]} {$joinArg[3]} AND ";

                    } else {
                        throw new Exception('Unknown JOIN argument');

                    }
                }

                $query = substr($query, 0, -5);
            } else {
                if ($join['operator'] === null) {
                    throw new Exception('Operator can\'t be null');
                }

                if ($join['second'] === null) {
                    throw new Exception('Second parameter can\'t be null');
                }

                $query .= "{$join['first']} {$join['operator']} {$join['second']}";
            }
        }

        if ($this->hasWhere()) {
            $query .= "\nWHERE\n\t" . trim($this->getWhereSql());
        }

        if (sizeof($this->groupBy) > 0) {
            $query .= "\nGROUP BY";
            foreach ($this->groupBy as $r) {
                $query .= " {$r['field']},";
            }
            $query = substr($query, 0, -1);
        }

        $sizeofHaving = count($this->having);
        if ($sizeofHaving > 0) {
            $query .= "\nHAVING";
            if ($sizeofHaving == 1) {
                $nl = ' ';
            } else {
                $nl = "\n\t";
            }

            foreach ($this->having as $index => $having) {
                $link = ($index > 0) ? "{$having['link']} " : '';
                if ($having['value'] instanceof Expr) {
                    $query .= "{$nl}{$link}{$having['field']} {$having['operator']} {$having['value']}";
                } else {
	                //$bindName = $this->bind($having['field'], $having['value'], 'h');
	                $bindName = $this->getBindings()->makeAndSet('h' . $having['field'], $having['value']);
	                $query .= "{$nl}{$link}{$having['field']} {$having['operator']} :{$bindName}";
                }
            }
        }

        if (sizeof($this->orderBy) > 0) {
            $query .= "\nORDER BY";
            foreach ($this->orderBy as $r) {
                $query .= "\n\t{$r['field']} {$r['direction']},";
            }
            $query = substr($query, 0, -1);
        }

        if ($this->limit !== null) {
            $query .= "\nLIMIT {$this->limit->howMuch} OFFSET {$this->limit->start}";
        }

        return new Query($query, $this->getBindings(), $this->getAdapterConnection());
    }
929963
public function buildQuery($query = null)
    {
        if (null === $query) {
            $query = $this->query;
        }

        $sql = "SELECT ";
        if (isset($query['distinct']) && $query['distinct']) {
            $sql .= 'DISTINCT ';
        }
        $sql .= isset($query['select']) ? $query['select'] : '*';

        if (!isset($query['from'])) {
            return false;
        }

        $sql .= "\nFROM " . $query['from'];
        if (isset($query['join'])) {
            $sql .= "\n" . (is_array($query['join']) ? implode("\n", $query['join']) : $query['join']);
        }
        if (isset($query['where']) && $query['where'] !== '') {
            $sql .= "\nWHERE " . $query['where'];
        }
        if (isset($query['group'])) {
            $sql .= "\nGROUP BY " . $query['group'];
            if (isset($query['having'])) {
                $sql .= "\nHAVING " . $query['having'];
            }
        }
        if (isset($query['order'])) {
            $sql .= "\n ORDER BY " . $query['order'];
        }
        $limit = isset($query['limit']) ? $query['limit'] : 0;
        $offset = isset($query['offset']) ? $query['offset'] : 0;
        $sql = $this->db->buildLimitOffset($sql, $limit, $offset);

        if (isset($query['union'])) {
            $sql .= "\n" . (is_array($query['union']) ? implode("\n", $query['union']) : $query['union']);
        }

        return $sql;
    }
939107
protected function _fetchTableInfo($table)
    {
        $return = null;
        $query  = $this->getObject('lib:database.query.show')
            ->show('TABLE STATUS')
            ->like(':like')
            ->bind(array('like' => $table));

        if($info = $this->select($query, KDatabase::FETCH_OBJECT)) {
            $return = $this->_parseTableInfo($info);
        }

        return $return;
    }
1165563
public List<Entity> findLike(String tableName, String field, String value, LikeType likeType) throws SQLException {
		return findAll(Entity.create(tableName).set(field, SqlUtil.buildLikeValue(value, likeType, true)));
	}
257029
public function getTables(string &$query) : array
    {
        $tables = [];
        foreach ($this->tables as &$table) {
            if (strpos($query, $table['table_name']) !== false) {
                $tables[] = $table['table_name'];
            }
        }

        unset($table);
        return $tables;
    }
564068
public function query($q = null)
    {
        return User::where(function ($query) use ($q) {
            $query->where('email', 'like', "%{$q}")
                ->orWhere('name', 'like', "%{$q}");
        })->orderBy('email')->paginate();
    }
160178
public function findAll($query = null) {
        if ($query === null) {
            $mapping = $this->getMapping();
            $table = $this->escapeIdentifier($mapping['table']);
            $query = 'select * from '.$table;
        }
        return $this->getWorker()->findAll($query);
    }
370764
public static function showDbTables($dbname, $where = null)
    {
        $query = static::getQuery(true);

        $query->select('table_name AS "Name"')
            ->from('information_schema.tables')
            ->where('table_type=' . $query->quote('BASE TABLE'))
            ->where(
                'table_schema NOT IN (' . $query->quote('pg_catalog') . ', ' . $query->quote('information_schema') . ')'
            )
            ->order('table_name ASC');

        if ($where) {
            $query->where($where);
        }

        return (string) $query;
    }
344900
public function GetListOfTablesInDatabase() {
        $dbConfig = new \Puzzlout\Framework\Dal\DbStatementConfig(null, \Puzzlout\Framework\Dal\DbExecutionType::SHOWTABLES, new \Puzzlout\Framework\Dal\DbQueryFilters());
        $dbConfig->setQuery("SHOW TABLES;");
        $this->addDbConfigItem($dbConfig);
        return $this->BindParametersAndExecute();
    }
777416
public function getTables()
    {
        $query = $this
            ->getSelectQuery('tablename')
            ->from('pg_tables')
            ->where("tablename NOT LIKE 'pg\\_%'")
            ->where("tablename NOT LIKE 'sql\\_%'")
            ->getQuery();
        
        return $this->query($query);
    }
34856
public function getDatabases(string $like = null): array
    {
        $sql = 'SHOW DATABASES;';
        if ($like !== null) {
            $sql = sprintf('SHOW DATABASES WHERE `database` LIKE %s;', $this->quoter->quoteValue($like));
        }

        return $this->db->queryValues($sql, 'Database');
    }
593825
public function whereLike($expr, $like)
    {
        if ($like === '') {
            return $this;
        }

        if (is_array($expr)) {
            $conditions = [];
            /** @noinspection ForeachSourceInspection */
            foreach ($expr as $field) {
                $key = strtr($field, '.', '_');
                if (strpos($field, '.') !== false) {
                    $conditions[] = '[' . str_replace('.', '].[', $field) . ']' . ' LIKE :' . $key;
                } else {
                    $conditions[] = '[' . $field . '] LIKE :' . $key;
                }

                $this->_bind[$key] = $like;
            }

            $this->_conditions[] = implode(' OR ', $conditions);
        } else {
            $key = strtr($expr, '.', '_');

            if (strpos($expr, '[') === false && strpos($expr, '(') === false) {
                if (strpos($expr, '.') !== false) {
                    $expr = '[' . str_replace('.', '].[', $expr) . ']';
                } else {
                    $expr = '[' . $expr . ']';
                }
            }

            $this->_conditions[] = $expr . ' LIKE :' . $key;

            $this->_bind[$key] = $like;
        }

        return $this;
    }
1024110
public function listTables()
    {
        $nextTableName = null;
        $tables = array();

        do {
            $options = new QueryTablesOptions();
            $options->setNextTableName($nextTableName);
            $result = $this->_tableProxy->queryTables();
            $nextTableName = $result->getNextTableName();
            $tables = array_merge($tables, $result->getTables());
        } while (!is_null($nextTableName));

        return $tables;
    }
31472
public function get(
        $where = null,
        $order = null,
        $limit = null,
        $offset = null,
        $columns = null,
        $group = null,
        $having = null
    ) {
        $result = parent::get($where, $order, $limit, $offset, $columns, $group, $having);
        return $result;
    }