/** * Executes the SQL query in this PreparedStatement object and returns the resultset generated by the query. * We support two signatures for this method: * - $stmt->executeQuery(ResultSet::FETCHMODE_NUM); * - $stmt->executeQuery(array($param1, $param2), ResultSet::FETCHMODE_NUM); * @param mixed $p1 Either (array) Parameters that will be set using PreparedStatement::set() before query is executed or (int) fetchmode. * @param int $fetchmode The mode to use when fetching the results (e.g. ResultSet::FETCHMODE_NUM, ResultSet::FETCHMODE_ASSOC). * @return ResultSet * @throws SQLException if a database access error occurs. */ public function executeQuery($p1 = null, $fetchmode = null) { $params = null; if ($fetchmode !== null) { $params = $p1; } elseif ($p1 !== null) { if (is_array($p1)) { $params = $p1; } else { $fetchmode = $p1; } } foreach ((array) $params as $i => $param) { $this->set($i + 1, $param); unset($i, $param); } unset($params); $this->updateCount = null; // reset $sql = $this->replaceParams(); if ($this->limit > 0 || $this->offset > 0) { $this->conn->applyLimit($sql, $this->offset, $this->limit); } $this->resultSet = $this->conn->executeQuery($sql, $fetchmode); return $this->resultSet; }
/** * Executes the SQL query in this PreparedStatement object and returns the resultset generated by the query. * We support two signatures for this method: * - $stmt->executeQuery(ResultSet::FETCHMODE_NUM); * - $stmt->executeQuery(array($param1, $param2), ResultSet::FETCHMODE_NUM); * @param mixed $p1 Either (array) Parameters that will be set using PreparedStatement::set() before query is executed or (int) fetchmode. * @param int $fetchmode The mode to use when fetching the results (e.g. ResultSet::FETCHMODE_NUM, ResultSet::FETCHMODE_ASSOC). * @return ResultSet * @throws SQLException if a database access error occurs. */ public function executeQuery($p1 = null, $fetchmode = null) { $params = null; if ($fetchmode !== null) { $params = $p1; } elseif ($p1 !== null) { if (is_array($p1)) { $params = $p1; } else { $fetchmode = $p1; } } if ($params) { for ($i = 0, $cnt = count($params); $i < $cnt; $i++) { $this->set($i + 1, $params[$i]); } } $this->updateCount = null; // reset $sql = $this->replaceParams(); if ($this->limit > 0 || $this->offset > 0) { $this->conn->applyLimit($sql, $this->offset, $this->limit); } $this->resultSet = $this->conn->executeQuery($sql, $fetchmode); return $this->resultSet; }
/** * Test the applyLimit() method. By default this method will not modify the values provided. * Subclasses must override this method to test for appropriate SQL modifications. */ public function testApplyLimit() { $sql = "SELECT * FROM sampletable WHERE category = 5"; $offset = 5; $limit = 50; $this->conn->applyLimit($sql, $offset, $limit); $this->assertEquals("SELECT * FROM sampletable WHERE category = 5 LIMIT 50 OFFSET 5", $sql); }
/** * Executes the SQL query in this PreparedStatement object and returns the resultset generated by the query. * * @param string $sql This method may optionally be called with the SQL statement. * @param int $fetchmode The mode to use when fetching the results (e.g. ResultSet::FETCHMODE_NUM, ResultSet::FETCHMODE_ASSOC). * @return object Creole::ResultSet * @throws SQLException If there is an error executing the specified query. * @todo -cStatementCommon Put native query execution logic in statement subclasses. */ public function executeQuery($sql, $fetchmode = null) { $this->updateCount = null; if ($this->limit > 0 || $this->offset > 0) { $this->conn->applyLimit($sql, $this->offset, $this->limit); } $this->resultSet = $this->conn->executeQuery($sql, $fetchmode); return $this->resultSet; }
/** * @see Connection::applyLimit() */ public function applyLimit(&$sql, $offset, $limit) { $this->log("applyLimit(): {$sql}, offset: {$offset}, limit: {$limit}"); return $this->childConnection->applyLimit($sql, $offset, $limit); }
/** * @see Connection::applyLimit() */ public function applyLimit(&$sql, $offset, $limit) { //$this->log("applyLimit(): $sql, offset: $offset, limit: $limit"); return $this->childConnection->applyLimit($sql, $offset, $limit); }
/** * @see Connection::applyLimit() */ public function applyLimit(&$sql, $offset, $limit) { krumo('DBArrayConnection applyLimit '); die; $this->log("applyLimit(): {$sql}, offset: {$offset}, limit: {$limit}"); return $this->childConnection->applyLimit($sql, $offset, $limit); }