/** * @param $result * * @return array */ private function fetchJoin($result) { $joins = $this->_queryBuilder->getJoins(); if (count($joins) > 0) { $fetched = array(); $i = 0; // loop trough results foreach ($result as $res) { // add result to array $fetched[$i] = $res; foreach ($joins as $join) { $fetched[$i][$join->getIdentifier()] = array(); // loop trough join data foreach ($join->getData() as $joinData) { // if there are join values then add to array if ($this->getJoinValues($res, $join, $joinData)) { $fetched[$i][$join->getIdentifier()][] = $this->getJoinValues($res, $join, $joinData); } } } ++$i; } $result = $fetched; } return $result; }
/** * @return array * * @throws \Doctrine\DBAL\DBALException */ private function prepareResults() { $sql = $this->sql; /** @var \Doctrine\DBAL\Connection $pdoConnection */ $pdoConnection = $this->queryBuilder->getConnection(); /** @var \Doctrine\DBAL\Statement $pdo **/ $pdo = $pdoConnection->prepare($sql); $pdo = $this->bindParameters($pdo, $this->getParameters()); $pdo->execute(); $results = $pdo->fetchAll(); $result = array(); foreach ($results as $res) { $result[] = $this->convertResults($res); } // $result = $this->fetchJoin($result); // $resultChain = $this->_queryBuilder->getClass()->getPivotResultChain(); // // $result = $resultChain->getResults($this->_queryBuilder->getClass()->getInvokeColumns()->getColumns(), $result); // exit; return $result; }