1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| function account_overview (PDO $pdo, $code = "", & $results) {
if ($code > 1000)
return;
if (!$pdo)
throw new RuntimeException("Expecting a valid PDO instance");
if (!$results)
$results = array();
try {
$stmt = $pdo->prepare('SELECT acc_name, code FROM compte_comptable WHERE parent_code=:code');
$stmt->bindParam(':code', $code, PDO::PARAM_STR);
if (!$stmt->execute())
throw new RuntimeException("Query Error");
$stmt->setFetchMode(PDO::FETCH_ASSOC);
foreach ($stmt as $row) {
$result[$row['code']] = $row['acc_name'];
account_overview($pdo, $row['code'], $results);
}
return $results;
}
catch (Exception $e) {
trigger_error((string)$e, E_USER_WARNING);
return false;
}
} |