Fetch all results from this query and get array of stdClass instances or your custom class instances

@param string $class

@return array
@throws QueryException
@throws \Koldy\Exception
481550
public function fetchAllObj(string $class = null): array
    {
        if (!$this->wasExecuted()) {
            $this->exec();
        }

        if ($class === null) {
            return $this->getAdapter()->getStatement()->fetchAll(\PDO::FETCH_OBJ);
        } else {
            $objectInstances = [];

            foreach ($this->fetchAll() as $r) {
                $objectInstances[] = new $class($r);
            }

            return $objectInstances;
        }
    }
1253965
protected function getMetadata($class)
    {
        if (array_key_exists($class, $this->cache)) {
            return $this->cache[$class];
        }

        $this->cache[$class] = null;

        foreach ($this->registry->getManagers() as $name => $em) {
            try {
                return $this->cache[$class] = [$em->getClassMetadata($class), $name];
            } catch (MappingException $e) {
                // not an entity or mapped super class
            } catch (LegacyMappingException $e) {
                // not an entity or mapped super class, using Doctrine ORM 2.2
            }
        }

        return $this->cache[$class];
    }
460492
public function get($class, $identifier)
    {
        $id = $this->getId($class, $identifier);
        if (!$id) {
            return null;
        }

        // If the class doesn't exist, look for a table instead
        if (!class_exists($class)) {
            $tableNames = DataObject::getSchema()->getTableNames();
            $potential = array_search($class, $tableNames);
            if (!$potential) {
                throw new \LogicException("'$class' is neither a class nor a table name");
            }
            $class = $potential;
        }

        return DataObject::get_by_id($class, $id);
    }
74759
public function fetchAllClass(string $classname) : array
    {
        $this->stmt->setFetchMode(\PDO::FETCH_CLASS, $classname);
        return $this->stmt->fetchAll();
    }
130361
public function resolveClass( $class )
	{
		if ( !is_string( $class ) )
			throw new ResolverException( "Class must be a string" );

		// Check if a class has been mapped to a key
		if ( array_key_exists( $class, $this->classAlias ) )
			try
			{
				return $this->resolve( null, $this->classAlias[$class] );
			}
			catch ( ResolverException $e )
			{
				// Ignore
			}

		// Check if the class has been initialized
		foreach ( $this->instances as $instance )
			if ( get_class( $instance ) == $class )
				return $instance;

		// TODO Other methods to check?

		return false;
	}
21263
public function loadClass( $class ) {

		if ( ! isset( $this->class_map[ $class ] ) )
			return FALSE;

		return $this->loader->loadFile( $this->class_map[ $class ] );
	}
375008
public function database_extensions($class)
    {
        $extensions = Config::inst()->get($class, 'database_extensions', Config::UNINHERITED);
        if ($extensions) {
            return $extensions;
        } else {
            return false;
        }
    }
580606
public function getExtendedClass($class)
    {
        $ret = null;
        if (array_key_exists($class, $this->dynamicClasses)) {
            $ret = $this->dynamicClasses[$class];
        }
        if (!$ret) {
            $ret = array_search($class, $this->classes);
        }
        return $ret?$ret:null;
    }
189892
protected function buildCustomDatabaseIndexes($class)
    {
        $indexes = [];
        $classIndexes = Config::inst()->get($class, 'indexes', Config::UNINHERITED) ?: [];
        foreach ($classIndexes as $indexName => $indexSpec) {
            if (array_key_exists($indexName, $indexes)) {
                throw new InvalidArgumentException(sprintf(
                    'Index named "%s" already exists on class %s',
                    $indexName,
                    $class
                ));
            }
            if (is_array($indexSpec)) {
                if (!ArrayLib::is_associative($indexSpec)) {
                    $indexSpec = [
                        'columns' => $indexSpec,
                    ];
                }
                if (!isset($indexSpec['type'])) {
                    $indexSpec['type'] = 'index';
                }
                if (!isset($indexSpec['columns'])) {
                    $indexSpec['columns'] = [$indexName];
                } elseif (!is_array($indexSpec['columns'])) {
                    throw new InvalidArgumentException(sprintf(
                        'Index %s on %s is not valid. columns should be an array %s given',
                        var_export($indexName, true),
                        var_export($class, true),
                        var_export($indexSpec['columns'], true)
                    ));
                }
            } else {
                $indexSpec = [
                    'type' => 'index',
                    'columns' => [$indexName],
                ];
            }
            $indexes[$indexName] = $indexSpec;
        }
        return $indexes;
    }
636246
public function getTraits(string $class){
        if(!class_exists($class)){
            throw new \InvalidArgumentException();
        }

        if(!array_key_exists($class, $this->traits)){
            $traits     = array_map(
                function($v){
                    return false;
                },
                array_flip(class_uses($class))
            );

            do{
                $continue   = false;
                $new        = [];

                foreach($traits as $trait => $flag){
                    if($flag === false){
                        $traits[$trait] = true;

                        foreach(class_uses($trait) as $use){
                            if(!array_key_exists($use, $traits)){
                                $continue   = true;
                                $new[$use]  = false;
                            }
                        }
                    }
                }

                $traits += $new;
            }while($continue === true);

            $this->traits[$class]   = array_keys($traits);
        }

        return $this->traits[$class];
    }
383239
public function fetch($class, array $filters = [], array $sortBy = null, $page = 0, $limit = -1, $count = false)
    {
        try {
            return $this->get($class)->find($filters, $sortBy, $page, $limit, $count);
        } catch (FinderException $e) {
            $data = $this->om->getRepository($class)->findBy($filters, null, 0 < $limit ? $limit : null, $page);

            return $count ? count($data) : $data;
        }
    }
454174
public static function getInstance($class = null)
    {
        static $instance = [];
        if (!empty($class)) {
            if (!$instance || strtolower($class) !== strtolower(get_class($instance[0]))) {
                $instance[0] = new $class();
            }
        }
        if (!$instance) {
            $instance[0] = new Debugger();
        }

        return $instance[0];
    }
740726
protected function makeSchema(string $class): array
    {
        //Using as basement
        $schema = $this->schema;
        unset($schema[Record::MORPHED_ALIASES]);

        //We do not have this information in morphed relation but it's required for ManyToMany
        $schema[Record::WHERE] = [];

        //This must be unified in future, for now we can fetch columns directly from there
        $recordSchema = $this->orm->define($class, ORMInterface::R_SCHEMA);
        $schema[Record::RELATION_COLUMNS] = array_keys($recordSchema[Record::SH_DEFAULTS]);

        return $schema;
    }
1131758
public static function getAllClassTraits($class)
    {
        $results = [];

        foreach (array_merge([$class => $class], class_parents($class)) as $class) {
            $results += self::getAllTraits($class);
        }

        return array_unique($results);
    }
456168
public function all(string $class=""): \ArrayIterator
    {
        return new \ArrayIterator(
            array_merge(
                $this->in($class)->getArrayCopy(), 
                $this->out($class)->getArrayCopy()
            )
        );
    }
816798
protected function findMetadata($class)
    {
        $metadata = null;

        try {
            // We could not use the hasMetadataFor() method as it is not working if the entity is not loaded. But
            // the getMetadataFor() method could throw an exception if the class is not found
            $metadata = $this->entityManager->getMetadataFactory()->getMetadataFor($class);
        } catch (Exception $exception) {
            // If an exception is raised, nothing to do. Extra data from metadata will be not used.
        }

        return $metadata;
    }
899563
public function loadObject($class = 'stdClass')
	{
		// Initialise variables
		$return = null;

		// Execute the query
		if (!$this->execute())
		{
			return null;
		}

		// Get the first row from the result set as an object of type $class
		if ($row = $this->fetchObject($class))
		{
			$return = $row;
		}

		// Free up system resources and return
		$this->freeResult();

		return $return;
	}