From 1e3f74ea7a76a989969c3cbebef271c442eac448 Mon Sep 17 00:00:00 2001 From: "Paul M. Jones" Date: Thu, 20 Feb 2014 15:40:40 -0600 Subject: [PATCH] rename fetchStatement() to perform() --- src/ExtendedPdo.php | 30 +++++++++++++++--------------- src/ExtendedPdoInterface.php | 2 +- tests/src/ExtendedPdoTest.php | 12 ++++++------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/ExtendedPdo.php b/src/ExtendedPdo.php index 53170a89..8da3718e 100644 --- a/src/ExtendedPdo.php +++ b/src/ExtendedPdo.php @@ -361,9 +361,9 @@ public function prepare($statement, $options = array()) * Connects to the database and prepares an SQL statement to be executed, * using values that been bound for the next query. * - * This override only binds values that have named placeholders in the + * This method only binds values that have named placeholders in the * statement, thereby avoiding errors from PDO regarding too many bound - * values; it also binds all sequential (question-mark) placeholders. + * values. It also binds all sequential (question-mark) placeholders. * * If a placeholder value is an array, the array is converted to a string * of comma-separated quoted values; e.g., for an `IN (...)` condition. @@ -377,7 +377,7 @@ public function prepare($statement, $options = array()) * @see http://php.net/manual/en/pdo.prepare.php * */ - protected function prepareFetch($statement) + protected function performPrepare($statement) { // are there any bind values? if (! $this->bind_values) { @@ -626,7 +626,7 @@ public function lastInsertId($name = null) */ public function fetchAll($statement, array $values = array(), $callable = null) { - $sth = $this->fetchStatement($statement, $values); + $sth = $this->perform($statement, $values); $data = $sth->fetchAll(self::FETCH_ASSOC); if ($callable) { foreach ($data as $key => $row) { @@ -657,7 +657,7 @@ public function fetchAll($statement, array $values = array(), $callable = null) */ public function fetchAssoc($statement, array $values = array(), $callable = null) { - $sth = $this->fetchStatement($statement, $values); + $sth = $this->perform($statement, $values); $data = array(); if ($callable) { while ($row = $sth->fetch(self::FETCH_ASSOC)) { @@ -689,7 +689,7 @@ public function fetchAssoc($statement, array $values = array(), $callable = null */ public function fetchCol($statement, array $values = array(), $callable = null) { - $sth = $this->fetchStatement($statement, $values); + $sth = $this->perform($statement, $values); $data = $sth->fetchAll(self::FETCH_COLUMN, 0); if ($callable) { foreach ($data as $key => $val) { @@ -727,7 +727,7 @@ public function fetchObject( $class_name = 'StdClass', array $ctor_args = array() ) { - $sth = $this->fetchStatement($statement, $values); + $sth = $this->perform($statement, $values); return $sth->fetchObject($class_name, $ctor_args); } @@ -761,7 +761,7 @@ public function fetchObjects( $class_name = 'StdClass', array $ctor_args = array() ) { - $sth = $this->fetchStatement($statement, $values); + $sth = $this->perform($statement, $values); return $sth->fetchAll(self::FETCH_CLASS, $class_name, $ctor_args); } @@ -778,7 +778,7 @@ public function fetchObjects( */ public function fetchOne($statement, array $values = array()) { - $sth = $this->fetchStatement($statement, $values); + $sth = $this->perform($statement, $values); return $sth->fetch(self::FETCH_ASSOC); } @@ -799,7 +799,7 @@ public function fetchOne($statement, array $values = array()) */ public function fetchPairs($statement, array $values = array(), $callable = null) { - $sth = $this->fetchStatement($statement, $values); + $sth = $this->perform($statement, $values); if ($callable) { $data = array(); while ($row = $sth->fetch(self::FETCH_NUM)) { @@ -816,19 +816,19 @@ public function fetchPairs($statement, array $values = array(), $callable = null /** * - * Fetches the result as a PDOStatement. + * Performs a query and returns a PDOStatement. * - * @param string $statement The SQL statement to prepare and execute. + * @param string $statement The SQL statement to perform. * * @param array $values Values to bind to the query. * * @return PDOStatement * */ - public function fetchStatement($statement, array $values = array()) + public function perform($statement, array $values = array()) { $this->bind_values = $values; - $sth = $this->prepareFetch($statement); + $sth = $this->performPrepare($statement); $this->beginProfile(__FUNCTION__); $sth->execute(); $this->endProfile($sth->queryString); @@ -849,7 +849,7 @@ public function fetchStatement($statement, array $values = array()) */ public function fetchValue($statement, array $values = array()) { - $sth = $this->fetchStatement($statement, $values); + $sth = $this->perform($statement, $values); return $sth->fetchColumn(0); } diff --git a/src/ExtendedPdoInterface.php b/src/ExtendedPdoInterface.php index 273a83a8..4d1ed6e3 100644 --- a/src/ExtendedPdoInterface.php +++ b/src/ExtendedPdoInterface.php @@ -185,7 +185,7 @@ public function fetchPairs($statement, array $values = array(), $callable = null * @return PDOStatement * */ - public function fetchStatement($statement, array $values = array()); + public function perform($statement, array $values = array()); /** * diff --git a/tests/src/ExtendedPdoTest.php b/tests/src/ExtendedPdoTest.php index 53f645fa..bdd3bbe5 100755 --- a/tests/src/ExtendedPdoTest.php +++ b/tests/src/ExtendedPdoTest.php @@ -74,7 +74,7 @@ protected function insert(array $data) $cols = implode(', ', $cols); $vals = implode(', ', $vals); $stm = "INSERT INTO pdotest ({$cols}) VALUES ({$vals})"; - $this->pdo->fetchStatement($stm, $data); + $this->pdo->perform($stm, $data); } public function testGetDriver() @@ -124,10 +124,10 @@ public function testQuery() $this->assertEquals($expect, $actual); } - public function testFetchStatement() + public function testperform() { $stm = "SELECT * FROM pdotest WHERE id <= :val"; - $sth = $this->pdo->fetchStatement($stm, array('val' => '5')); + $sth = $this->pdo->perform($stm, array('val' => '5')); $this->assertInstanceOf('PDOStatement', $sth); $result = $sth->fetchAll(Pdo::FETCH_ASSOC); $expect = 5; @@ -139,7 +139,7 @@ public function testQueryWithArrayValues() { $stm = "SELECT * FROM pdotest WHERE id IN (:list) OR id = :id"; - $sth = $this->pdo->fetchStatement($stm, array( + $sth = $this->pdo->perform($stm, array( 'list' => array(1, 2, 3, 4), 'id' => 5 )); @@ -195,7 +195,7 @@ public function testPrepareWithQuotedStringsAndData() AND id IN (:list) AND \"leave '':bar' alone\""; - $sth = $this->pdo->fetchStatement($stm, array( + $sth = $this->pdo->perform($stm, array( 'list' => array('1', '2', '3', '4', '5'), 'foo' => 'WRONG', 'bar' => 'WRONG', @@ -489,7 +489,7 @@ public function testProfiling() 'bind_values' => array(), ), 2 => array( - 'function' => 'fetchStatement', + 'function' => 'perform', 'statement' => 'SELECT 3 FROM pdotest', 'bind_values' => array( 'zim' => 'gir',