1
0
mirror of synced 2024-12-13 22:56:04 +03:00

- added colnum parameter to fetchOne and fetchColumn

- use fetchColumn() in fetchOne()
- removed PORTABILITY_FIX_CASE handling in fetchColumn() since this can be handled by PDO internally
This commit is contained in:
lsmith 2007-01-07 14:52:16 +00:00
parent 2933cd2dd1
commit 78ce54a7e5

View File

@ -489,10 +489,11 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* *
* @param string $statement sql query to be executed * @param string $statement sql query to be executed
* @param array $params prepared statement params * @param array $params prepared statement params
* @param int $colnum 0-indexed column number to retrieve
* @return mixed * @return mixed
*/ */
public function fetchOne($statement, array $params = array()) { public function fetchOne($statement, array $params = array(), $colnum = 0) {
return current($this->execute($statement, $params)->fetch(PDO::FETCH_NUM)); return $this->execute($statement, $params)->fetchColumn($colnum);
} }
/** /**
* fetchRow * fetchRow
@ -519,15 +520,11 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* *
* @param string $statement sql query to be executed * @param string $statement sql query to be executed
* @param array $params prepared statement params * @param array $params prepared statement params
* @param int $colnum 0-indexed column number to retrieve
* @return array * @return array
*/ */
public function fetchColumn($statement, array $params = array()) { public function fetchColumn($statement, array $params = array(), $colnum = 0) {
$result = $this->query($statement, $params)->fetchAll(PDO::FETCH_COLUMN); return $this->query($statement, $params)->fetchAll(PDO::FETCH_COLUMN, $colnum);
if ($this->options['portability'] & Doctrine::PORTABILITY_FIX_CASE) {
$result = array_map(($this->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
}
return $result;
} }
/** /**
* fetchAssoc * fetchAssoc