Update orm.php

Change the function fetch to fetchAll. Fetch returns a 2 dimensional array and fetchAll returns a 3 dimensional array. which changes the array structure so it works better with count.
This commit is contained in:
FusionPBX 2016-10-03 21:33:20 -06:00 committed by GitHub
parent 5bd3d3310d
commit bcb7881255
1 changed files with 6 additions and 5 deletions

View File

@ -364,15 +364,16 @@
//get the data //get the data
try { try {
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetch(PDO::FETCH_ASSOC); $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
} }
catch(PDOException $e) { catch(PDOException $e) {
echo 'Caught exception: ', $e->getMessage(), "<br/><br/>\n"; echo 'Caught exception: ', $e->getMessage(), "<br/><br/>\n";
echo $sql; echo $sql;
exit; exit;
} }
//set the action //set the action
if (is_array($result)) { if (count($result) > 0) {
$action = "update"; $action = "update";
$old_array[$schema_name][] = $result; $old_array[$schema_name][] = $result;
} }
@ -380,12 +381,12 @@
$action = "add"; $action = "add";
} }
} }
unset($prep_statement, $result); unset($prep_statement);
unset($result);
} }
else { else {
$action = "add"; $action = "add";
} }
//echo "action: ".$action."\n";
//add a record //add a record
if ($action == "add") { if ($action == "add") {
@ -887,7 +888,7 @@
return false; return false;
} }
} }
}ƒ }
//examples //examples
/* /*