Skip to content

Commit

Permalink
Fixed bug with getting keyed results
Browse files Browse the repository at this point in the history
  • Loading branch information
a1phanumeric authored Nov 29, 2023
1 parent 5e6459c commit 9c189d0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions DBPDO.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ function fetchAll($query, $values = null, $key = null){

// Allows the user to retrieve results using a
// column from the results as a key for the array
if($key != null && $results[0][$key]){
$keyed_results = array();
foreach($results as $result){
$keyed_results[$result[$key]] = $result;
if(!empty($results)){
if ($key != null && $results[0][$key]) {
$keyed_results = array();
foreach ($results as $result) {
$keyed_results[$result[$key]] = $result;
}
$results = $keyed_results;
}
$results = $keyed_results;
}
return $results;
}
Expand Down

0 comments on commit 9c189d0

Please sign in to comment.