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
|
||||
* @param string associative key
|
||||
* @param string value
|
||||
* @return array
|
||||
*/
|
||||
final function fetchPairs($key, $value)
|
||||
final function fetchPairs($key=NULL, $value=NULL)
|
||||
{
|
||||
@$this->seek(0);
|
||||
$rec = $this->fetch();
|
||||
if (!$rec)
|
||||
return array(); // empty resultset
|
||||
|
||||
if (!array_key_exists($key, $rec) ||
|
||||
!array_key_exists($value, $rec)) return FALSE;
|
||||
if ($value === NULL) {
|
||||
$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();
|
||||
do {
|
||||
|
Reference in New Issue
Block a user