src/Data/TableRowsAsRecordsDataProvider.php
public function fetch(ConfigInterface $config)
    {
        if (!$config->getId()) {
            throw new DcGeneralException(
                'Error, no id passed, TableRowsAsRecordsDriver is only intended for edit mode.',
                1
            );
        }

        $queryBuilder = $this->connection->createQueryBuilder();
        DefaultDataProviderDBalUtils::addField($config, $this->idProperty, $queryBuilder);
        $queryBuilder->from($this->source);
        $queryBuilder->where($queryBuilder->expr()->eq($this->strGroupCol, ':' . $this->strGroupCol));
        $queryBuilder->setParameter($this->strGroupCol, $config->getId());

        if ($this->strSortCol) {
            $queryBuilder->orderBy($this->strSortCol, 'ASC');
        }

        $statement = $queryBuilder->execute();

        $model = $this->getEmptyModel();
        $model->setID($config->getId());
        if (0 < $statement->rowCount()) {
            $model->setPropertyRaw('rows', $statement->fetchAll(\PDO::FETCH_ASSOC));
        }

        return $model;
    }
public function fetch(ConfigInterface $config)
    {
        if (!$config->getId()) {
            throw new DcGeneralException(
                'Error, no id passed, TableRowsAsRecordsDriver is only intended for edit mode.',
                1
            );
        }

        $queryBuilder = $this->connection->createQueryBuilder();
        DefaultDataProviderDBalUtils::addField($config, $this->idProperty, $queryBuilder);
        $queryBuilder->from($this->source);
        $queryBuilder->where($queryBuilder->expr()->eq($this->strGroupCol, ':' . $this->strGroupCol));
        $queryBuilder->setParameter($this->strGroupCol, $config->getId());

        if ($this->strSortCol) {
            $queryBuilder->orderBy($this->strSortCol, 'ASC');
        }

        $statement = $queryBuilder->execute();

        $model = $this->getEmptyModel();
        $model->setID($config->getId());
        if (0 < $statement->rowCount()) {
            $model->setPropertyRaw('rows', $statement->fetchAll(\PDO::FETCH_ASSOC));
        }

        return $model;
    }
public function fetch ( ConfigInterface $ config ) { if ( ! $ config -> getId ( ) ) { throw new DcGeneralException ( 'Error, no id passed, TableRowsAsRecordsDriver is only intended for edit mode.' , 1 ) ; } $ queryBuilder = $ this -> connection -> createQueryBuilder ( ) ; DefaultDataProviderDBalUtils :: addField ( $ config , $ this -> idProperty , $ queryBuilder ) ; $ queryBuilder -> from ( $ this -> source ) ; $ queryBuilder -> where ( $ queryBuilder -> expr ( ) -> eq ( $ this -> strGroupCol , ':' . $ this -> strGroupCol ) ) ; $ queryBuilder -> setParameter ( $ this -> strGroupCol , $ config -> getId ( ) ) ; if ( $ this -> strSortCol ) { $ queryBuilder -> orderBy ( $ this -> strSortCol , 'ASC' ) ; } $ statement = $ queryBuilder -> execute ( ) ; $ model = $ this -> getEmptyModel ( ) ; $ model -> setID ( $ config -> getId ( ) ) ; if ( 0 < $ statement -> rowCount ( ) ) { $ model -> setPropertyRaw ( 'rows' , $ statement -> fetchAll ( \ PDO :: FETCH_ASSOC ) ) ; } return $ model ; }
Fetch a single record by id.

This data provider only supports retrieving by id so use $objConfig->setId() to populate the config with an Id.

@param ConfigInterface $config The configuration to use.

@return ModelInterface

@throws DcGeneralException If config object does not contain an Id.
Fetch a single record by id .