Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- $query = "SELECT CONCAT(firstName, lastName) AS name ";
- $query .= "FROM people AS p ";
- $query .= "WHERE p.age=:age ";
- $query .= "ORDER BY name DESC ";
- $statement = $pdoRef->prepare($query);
- $statement->bindParam(":age", $age, PDO::PARAM_INT);
- if (!$statement->execute())
- throw new Exception("Statement did not execute");
- $result = $statement->fetchAll();
- if (count($result) === 0)
- throw new Exception("0 Results");
- foreach ($result as $person) {
- //
- }
- } catch (PDOException $ex) {
- // do something with $ex->getMessage();
- } catch (Exception $ex) {
- // do something with $ex->getMessage();
- }
Add Comment
Please, Sign In to add comment