Skip to content

Commit

Permalink
Added third an optional argument types to use prepared statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Timoshenko authored and Igor committed Sep 16, 2012
1 parent a5979b3 commit 8382fef
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -369,43 +369,46 @@ public function setFetchMode($fetchMode)
} }


/** /**
* Prepares and executes an SQL query and returns the first row of the result * Prepares and executes the SQL-query and returns the first row of the result
* as an associative array. * as an associative array
* *
* @param string $statement The SQL query. * @param string $sql The SQL-query
* @param array $params The query parameters. * @param array $params An array of params
* @param array $types An array of types. For instance, PDO::PARAM* constants
* @return array * @return array
*/ */
public function fetchAssoc($statement, array $params = array()) public function fetchAssoc($sql, array $params = array(), array $types = array())
{ {
return $this->executeQuery($statement, $params)->fetch(PDO::FETCH_ASSOC); return $this->executeQuery($sql, $params, $types)->fetch(PDO::FETCH_ASSOC);
} }


/** /**
* Prepares and executes an SQL query and returns the first row of the result * Prepares and executes the SQL query and returns the first row of the result
* as a numerically indexed array. * as a numerically indexed array
* *
* @param string $statement sql query to be executed * @param string $sql The SQL-query
* @param array $params prepared statement params * @param array $params An array of params
* @param array $types An array of types. For instance, PDO::PARAM* constants
* @return array * @return array
*/ */
public function fetchArray($statement, array $params = array()) public function fetchArray($sql, array $params = array(), array $types = array())
{ {
return $this->executeQuery($statement, $params)->fetch(PDO::FETCH_NUM); return $this->executeQuery($sql, $params, $types)->fetch(PDO::FETCH_NUM);
} }


/** /**
* Prepares and executes an SQL query and returns the value of a single column * Prepares and executes the SQL-query and returns the value of a single column
* of the first row of the result. * of the first row of the result
* *
* @param string $statement sql query to be executed * @param string $sql The SQL-query
* @param array $params prepared statement params * @param array $params An array of params
* @param int $colnum 0-indexed column number to retrieve * @param array $types An array of types. For instance, PDO::PARAM* constants
* @return mixed * @param integer $colnum 0-indexed column number to retrieve
* @return string
*/ */
public function fetchColumn($statement, array $params = array(), $colnum = 0) public function fetchColumn($sql, array $params = array(), array $types = array(), $colnum = 0)
{ {
return $this->executeQuery($statement, $params)->fetchColumn($colnum); return $this->executeQuery($sql, $params, $types)->fetchColumn($colnum);
} }


/** /**
Expand Down Expand Up @@ -573,15 +576,16 @@ public function quote($input, $type = null)
} }


/** /**
* Prepares and executes an SQL query and returns the result as an associative array. * Prepares and executes an SQL query and returns the result as an associative array
* *
* @param string $sql The SQL query. * @param string $sql The SQL query
* @param array $params The query parameters. * @param array $params An array of params
* @param array $types An array of types. For instance, PDO::PARAM* constants
* @return array * @return array
*/ */
public function fetchAll($sql, array $params = array()) public function fetchAll($sql, array $params = array(), array $types = array())
{ {
return $this->executeQuery($sql, $params)->fetchAll(); return $this->executeQuery($sql, $params, $types)->fetchAll();
} }


/** /**
Expand Down

0 comments on commit 8382fef

Please sign in to comment.