Connection::getTables

Get list of current database tables.

@param bool $prefixLimit If sets TRUE the query will be limit using database table prefix.

@return array Returns an array
@throws \O2System\Spl\Exceptions\RuntimeException
978138
public function getTables($prefixLimit = false)
    {
        if (empty($this->queriesResultCache[ 'tableNames' ])) {

            $sqlStatement = 'SELECT "NAME" FROM "SQLITE_MASTER" WHERE "TYPE" = \'table\'';

            if ($prefixLimit !== false && $this->config[ 'tablePrefix' ] !== '') {
                $sqlStatement .= ' AND "NAME" LIKE \'' . $this->escapeLikeString($this->config[ 'tablePrefix' ]) . "%' ";
            }

            $result = $this->query($sqlStatement);

            if ($result->count()) {
                foreach ($result as $row) {
                    // Do we know from which column to get the table name?
                    if ( ! isset($key)) {
                        if (isset($row[ 'table_name' ])) {
                            $key = 'table_name';
                        } elseif (isset($row[ 'TABLE_NAME' ])) {
                            $key = 'TABLE_NAME';
                        } else {
                            /* We have no other choice but to just get the first element's key.
                             * Due to array_shift() accepting its argument by reference, if
                             * E_STRICT is on, this would trigger a warning. So we'll have to
                             * assign it first.
                             */
                            $key = array_keys($row->getArrayCopy());
                            $key = array_shift($key);
                        }
                    }

                    $this->queriesResultCache[ 'tableNames' ][] = $row->offsetGet($key);
                }
            }
        }

        return $this->queriesResultCache[ 'tableNames' ];
    }
904795
public function getJobs($limit = null)
    {
        $select = $this->getAdapter()->select();
        $select->from($this->jobTable)
               ->where("$this->jobStatusColumn = ?", JobInterface::STATUS_ACTIVE)
               ->order(array("$this->jobPriorityColumn DESC", "$this->jobDateLastRunColumn ASC"));
        
        if ($limit !== null) {
            $select->limit($limit);
        }
        
        $jobs = array();
        foreach ($select->query()->fetchAll() as $result) {
            $job = $this->createJobRowObject($result);
            $jobs[] = $job;
        }

        return $jobs;
    }
1367538
public function getAllowedDbValues(array $except = [])
    {
        $map      = $this->getMap();
        $dbValues = array_diff(array_keys($map), $except);

        return $dbValues;
    }
630554
public function getQueryResults($limit = null)
    {
        if (isset($limit)) {
            $this->queryBuilder->setMaxResults($limit);
        }
        
        if (!$this->queryBuilder->getDQLPart('orderBy')) {
            $this->queryBuilder->orderBy('a.createdAt', 'ASC');
        }

        return $this->queryBuilder->getQuery()->getResult();
    }
561271
protected function _list_tables($prefix_limit = FALSE)
	{
		$sql = 'SELECT "tabname" FROM "syscat"."tables"
			WHERE "type" = \'T\' AND LOWER("tabschema") = '.$this->escape(strtolower($this->database));

		if ($prefix_limit === TRUE && $this->dbprefix !== '')
		{
			$sql .= ' AND "tabname" LIKE \''.$this->escape_like_str($this->dbprefix)."%' "
				.sprintf($this->_like_escape_str, $this->_like_escape_chr);
		}

		return $sql;
	}
408837
public function getNodesByTable($database_table)
    {
        $list = $this->getTables();
        if (empty($list[$database_table])) {
            throw new QueryException('Not find :' . $database_table);
        }
        return $list[$database_table];
    }
1226470
public function get_users($userlimit = 0) {
        global $DB;
        $users = $DB->get_records_sql($this->sql, $this->params, 0, $userlimit);
        return $users;
    }
759354
public function get_entries($start=0, $limit=10) {
        global $DB;

        if ($this->entries === null) {
            if ($sqlarray = $this->get_entry_fetch_sql(false, 'created DESC')) {
                $this->entries = $DB->get_records_sql($sqlarray['sql'], $sqlarray['params'], $start, $limit);
                if (!$start && count($this->entries) < $limit) {
                    $this->totalentries = count($this->entries);
                }
            } else {
                return false;
            }
        }

        return $this->entries;
    }
1315769
public function getDataObjects($limit = 0, $start = 0) {

        $pagination = \PaginatedList::create($this->toArrayList())
			->setPageLength($limit)
			->setPageStart($start)
			->setTotalItems($this->getTotalResults())
			->setLimitItems(false);
		return $pagination;
    }
913693
protected function getLimitSql(array $sql): array
    {
        if (!isset($this->limit)) {
            return $sql;
        }
        $sql[] = sprintf('LIMIT %s', (int)$this->limit);

        return $sql;
    }
465273
public static function showTables($prefix)
    {
        $results = static::select('SHOW FULL TABLES');

        $tables = [];
        $views = [];
        $first = '';
        foreach ($results as $result) {
            // get the first element (table name)
            foreach ($result as $value) {
                $first = $value;
                break;
            }

            // skip all tables that are not the current prefix
            if (!empty($prefix)) {
                if (!starts_with($first, $prefix)) {
                    continue;
                }
            }

            // separate views from tables
            if ($result->Table_type == 'VIEW') {
                $views[] = $first;
            } else {
                $tables[] = $first;
            }
        }

        return ['tables' => $tables, 'views' => $views];
    }
462733
protected function getLimitQuery( $limits = array() )
	{
		if( is_array( $limits ) && count( $limits ) == 2 )
			$limits	= ' LIMIT '.$limits[0].', '.$limits[1];
		else if( is_int( $limits ) && $limits )
			$limits	= ' LIMIT 0, '.$limits;
		else
			$limits	= '';
		return $limits;
	}
935280
public static function GetTables ($forced_obtain = false, $options = []) {
		$options += $options + static::GetDefaultOptions();
		return DBI::GetTables($options, static::GetName(), $forced_obtain);
	}
1055964
public function findOpen($limit = 999): array
    {
        $queryBuilder = $this->createQuery();

        return (array)$queryBuilder->select('*')
            ->from($this->getTableName())
            ->where($queryBuilder->expr()->eq('call_date', $queryBuilder->createNamedParameter(0)))
            ->setMaxResults($limit)
            ->execute()
            ->fetchAll();
    }
254240
public function getTableList()
	{
		$this->connect();

		/* @type  SqliteQuery  $query */
		$query = $this->getQuery(true);

		$type = 'table';

		$query->select('name');
		$query->from('sqlite_master');
		$query->where('type = :type');
		$query->bind(':type', $type);
		$query->order('name');

		$this->setQuery($query);

		$tables = $this->loadColumn();

		return $tables;
	}
1241633
public function get_tables($usecache=true) {
        if ($usecache and $this->tables !== null) {
            return $this->tables;
        }
        $this->tables = array();
        $prefix = str_replace('_', "\\_", strtoupper($this->prefix));
        $sql = "SELECT TABLE_NAME
                  FROM CAT
                 WHERE TABLE_TYPE='TABLE'
                       AND TABLE_NAME NOT LIKE 'BIN\$%'
                       AND TABLE_NAME LIKE '$prefix%' ESCAPE '\\'";
        $this->query_start($sql, null, SQL_QUERY_AUX);
        $stmt = $this->parse_query($sql);
        $result = oci_execute($stmt, $this->commit_status);
        $this->query_end($result, $stmt);
        $records = null;
        oci_fetch_all($stmt, $records, 0, -1, OCI_ASSOC);
        oci_free_statement($stmt);
        $records = array_map('strtolower', $records['TABLE_NAME']);
        foreach ($records as $tablename) {
            if ($this->prefix !== false && $this->prefix !== '') {
                if (strpos($tablename, $this->prefix) !== 0) {
                    continue;
                }
                $tablename = substr($tablename, strlen($this->prefix));
            }
            $this->tables[$tablename] = $tablename;
        }

        // Add the currently available temptables
        $this->tables = array_merge($this->tables, $this->temptables->get_temptables());

        return $this->tables;
    }
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;
    }