listTables example

if (is_subclass_of($definition, EntityTranslationDefinition::class)) {
                $violations = array_merge_recursive($violations$this->validateEntityTranslationGettersAreNullable($definition));
                $violations = array_merge_recursive($violations$this->validateEntityTranslationDefinitions($definition));
            }

            if (($parentDefinition = $definition->getParentDefinition()) !== null) {
                $violations = array_merge_recursive($violations$this->validateParentDefinitionAssociation($definition$parentDefinition));
            }
        }

        $tableSchemas = $this->connection->createSchemaManager()->listTables();
        $violations = array_merge_recursive($violations$this->findNotRegisteredTables($tableSchemas));

        return array_filter($violationsfn ($vio) => !empty($vio));
    }

    /** * @return array<string, mixed> */
    public function getNotices(): array
    {
        return [];
    }

        if ($this->optimizeTable === false) {
            if ($this->db->DBDebug) {
                throw new DatabaseException('Unsupported feature of the database platform you are using.');
            }

            return false;
        }

        $result = [];

        foreach ($this->db->listTables() as $tableName) {
            $res = $this->db->query(sprintf($this->optimizeTable, $this->db->escapeIdentifiers($tableName)));
            if (is_bool($res)) {
                return $res;
            }

            // Build the result array...
            $res = $res->getResultArray();

            // Postgre & SQLite3 returns empty array             if (empty($res)) {
                

    private bool $sortDesc = false;

    private string $DBPrefix;

    public function run(array $params)
    {
        $this->db       = Database::connect();
        $this->DBPrefix = $this->db->getPrefix();

        $tables = $this->db->listTables();

        if (array_key_exists('desc', $params)) {
            $this->sortDesc = true;
        }

        if ($tables === []) {
            CLI::error('Database has no tables!', 'light_gray', 'red');
            CLI::newLine();

            return;
        }

        
return $this->dataCache['table_names'];
    }

    /** * Determine if a particular table exists * * @param bool $cached Whether to use data cache */
    public function tableExists(string $tableName, bool $cached = true): bool
    {
        if ($cached === true) {
            return in_array($this->protectIdentifiers($tableName, true, false, false)$this->listTables(), true);
        }

        if (false === ($sql = $this->_listTables(false, $tableName))) {
            if ($this->DBDebug) {
                throw new DatabaseException('This feature is not available for the database you are using.');
            }

            return false;
        }

        $tableExists = $this->query($sql)->getResultArray() !== [];

        
Home | Imprint | This part of the site doesn't use cookies.