- Patch #742042 by kkaefer:DBTNG: ->fetchAllAssoc() doesn't respect fetch mode set during ->execute().
parent
5f98fb812b
commit
9332e835da
|
@ -1916,12 +1916,13 @@ interface DatabaseStatementInterface extends Traversable {
|
||||||
* @param $fetch
|
* @param $fetch
|
||||||
* The fetchmode to use. If set to PDO::FETCH_ASSOC, PDO::FETCH_NUM, or
|
* The fetchmode to use. If set to PDO::FETCH_ASSOC, PDO::FETCH_NUM, or
|
||||||
* PDO::FETCH_BOTH the returned value with be an array of arrays. For any
|
* PDO::FETCH_BOTH the returned value with be an array of arrays. For any
|
||||||
* other value it will be an array of objects.
|
* other value it will be an array of objects. By default, the fetch mode
|
||||||
|
* set for the query will be used.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* An associative array.
|
* An associative array.
|
||||||
*/
|
*/
|
||||||
public function fetchAllAssoc($key, $fetch = PDO::FETCH_OBJ);
|
public function fetchAllAssoc($key, $fetch = NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1987,19 +1988,22 @@ class DatabaseStatementBase extends PDOStatement implements DatabaseStatementInt
|
||||||
return $this->fetchAll(PDO::FETCH_COLUMN, $index);
|
return $this->fetchAll(PDO::FETCH_COLUMN, $index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fetchAllAssoc($key, $fetch = PDO::FETCH_OBJ) {
|
public function fetchAllAssoc($key, $fetch = NULL) {
|
||||||
$return = array();
|
$return = array();
|
||||||
$this->setFetchMode($fetch);
|
if (isset($fetch)) {
|
||||||
if (in_array($fetch, array(PDO::FETCH_ASSOC, PDO::FETCH_NUM, PDO::FETCH_BOTH))) {
|
if (is_string($fetch)) {
|
||||||
foreach ($this as $record) {
|
$this->setFetchMode(PDO::FETCH_CLASS, $fetch);
|
||||||
$return[$record[$key]] = $record;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
$this->setFetchMode($fetch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this as $record) {
|
foreach ($this as $record) {
|
||||||
$return[$record->$key] = $record;
|
$record_key = is_object($record) ? $record->$key : $record[$key];
|
||||||
}
|
$return[$record_key] = $record;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2080,7 +2084,7 @@ class DatabaseStatementEmpty implements Iterator, DatabaseStatementInterface {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fetchAllAssoc($key, $fetch = PDO::FETCH_OBJ) {
|
public function fetchAllAssoc($key, $fetch = NULL) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -475,8 +475,8 @@ class DatabaseStatementPrefetch implements Iterator, DatabaseStatementInterface
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fetchAllAssoc($key, $fetch_style = PDO::FETCH_OBJ) {
|
public function fetchAllAssoc($key, $fetch_style = NULL) {
|
||||||
$this->fetchStyle = $fetch_style;
|
$this->fetchStyle = isset($fetch_style) ? $fetch_style : $this->defaultFetchStyle;
|
||||||
$this->fetchOptions = $this->defaultFetchOptions;
|
$this->fetchOptions = $this->defaultFetchOptions;
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
Loading…
Reference in New Issue