mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 13:47:33 +02:00
This commit is contained in:
@@ -238,17 +238,25 @@ abstract class DibiResult implements IteratorAggregate, Countable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches all records from table like $key => $value pairs
|
* Fetches all records from table like $key => $value pairs
|
||||||
|
* @param string associative key
|
||||||
|
* @param string value
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
final function fetchPairs($key, $value)
|
final function fetchPairs($key=NULL, $value=NULL)
|
||||||
{
|
{
|
||||||
@$this->seek(0);
|
@$this->seek(0);
|
||||||
$rec = $this->fetch();
|
$rec = $this->fetch();
|
||||||
if (!$rec)
|
|
||||||
return array(); // empty resultset
|
|
||||||
|
|
||||||
if (!array_key_exists($key, $rec) ||
|
if ($value === NULL) {
|
||||||
!array_key_exists($value, $rec)) return FALSE;
|
$tmp = array_keys($rec);
|
||||||
|
$key = $tmp[0];
|
||||||
|
$value = $tmp[1];
|
||||||
|
} else {
|
||||||
|
if (!array_key_exists($key, $rec)) return FALSE;
|
||||||
|
if (!array_key_exists($value, $rec)) return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$rec) return array(); // empty resultset
|
||||||
|
|
||||||
$arr = array();
|
$arr = array();
|
||||||
do {
|
do {
|
||||||
|
Reference in New Issue
Block a user