protected function query($query) { // check nosql configuration $configuration = $this->init_entity->getConnection()->getConfiguration(); if (isset($configuration['handlersocket']['read'])) { $nosqlConnectionName = $configuration['handlersocket']['read']; $nosqlConnection = Main\Application::getInstance()->getConnectionPool()->getConnection($nosqlConnectionName); $isNosqlCapable = NosqlPrimarySelector::checkQuery($nosqlConnection, $this); if ($isNosqlCapable) { $nosqlResult = NosqlPrimarySelector::relayQuery($nosqlConnection, $this); return new Main\DB\ArrayResult($nosqlResult); } } /* Vadim: this is for paging but currently is not used if ($this->count_total || !is_null($this->offset)) { $cnt_body_elements = $build_parts; // remove order unset($cnt_body_elements['ORDER BY']); $cnt_query = join("\n", $cnt_body_elements); // remove long aliases list($cnt_query, ) = $this->replaceSelectAliases($cnt_query); // select count $cnt_query = 'SELECT COUNT(1) AS TMP_ROWS_CNT FROM ('.$cnt_query.') xxx'; $cnt = $connection->queryScalar($cnt_query); } */ $connection = Main\Application::getConnection(); $result = $connection->query($query); $result->setReplacedAliases($this->replaced_aliases); if ($this->isFetchModificationRequired()) { $result->addFetchDataModifier(array($this, 'fetchDataModificationCallback')); } static::$last_query = $query; return $result; }
protected function query($query) { // check nosql configuration $connection = $this->init_entity->getConnection(); $configuration = $connection->getConfiguration(); if (isset($configuration['handlersocket']['read'])) { $nosqlConnectionName = $configuration['handlersocket']['read']; $nosqlConnection = Main\Application::getInstance()->getConnectionPool()->getConnection($nosqlConnectionName); $isNosqlCapable = NosqlPrimarySelector::checkQuery($nosqlConnection, $this); if ($isNosqlCapable) { $nosqlResult = NosqlPrimarySelector::relayQuery($nosqlConnection, $this); return new Main\DB\ArrayResult($nosqlResult); } } $cnt = null; if ($this->count_total) { $buildParts = $this->query_build_parts; //remove order unset($buildParts['ORDER BY']); //remove select $buildParts['SELECT'] = "1 cntholder"; foreach ($buildParts as $k => &$v) { $v = $k . ' ' . $v; } $cntQuery = join("\n", $buildParts); // select count $cntQuery = 'SELECT COUNT(cntholder) AS TMP_ROWS_CNT FROM (' . $cntQuery . ') xxx'; $cnt = $connection->queryScalar($cntQuery); } $result = $connection->query($query); $result->setReplacedAliases($this->replaced_aliases); if ($this->count_total) { $result->setCount($cnt); } if ($this->isFetchModificationRequired()) { $result->addFetchDataModifier(array($this, 'fetchDataModificationCallback')); } static::$last_query = $query; return $result; }