tlmarker1968

Untitled

Feb 2nd, 2020
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. More information I am trying. Here is the function I am using to get a grade name:
  2.  
  3.  
  4. public function getGrade($id) {
  5. var_dump($this->connection);
  6. var_dump($id);
  7. $sql = "SELECT grade FROM grades WHERE id=5";
  8. $stmt = $this->connection->prepare($sql);
  9. var_dump($stmt);
  10. $stmt->execute(['id' => $id]);
  11. var_dump($stmt);
  12. $grade = $stmt->fetchAll();
  13. var_dump($grade[0]['grade']);
  14. return $grade->grade;
  15. }
  16.  
  17. And here is the response I get from postman when I run the code:
  18.  
  19. C:\Users\tlmar\Documents\GitHub\Phoenix-API\src\Domain\Repository\Security.php:66:
  20. object(PDO)[156]
  21. C:\Users\tlmar\Documents\GitHub\Phoenix-API\src\Domain\Repository\Security.php:67:string '5' (length=1)
  22. C:\Users\tlmar\Documents\GitHub\Phoenix-API\src\Domain\Repository\Security.php:70:
  23. object(PDOStatement)[158]
  24. public 'queryString' => string 'SELECT grade FROM grades WHERE id=5' (length=35)
  25. C:\Users\tlmar\Documents\GitHub\Phoenix-API\src\Domain\Repository\Security.php:72:
  26. object(PDOStatement)[158]
  27. public 'queryString' => string 'SELECT grade FROM grades WHERE id=5' (length=35)
  28. C:\Users\tlmar\Documents\GitHub\Phoenix-API\src\Domain\Repository\Security.php:74:null
  29. {"success":true,"message":"User successfully retreived","data":{"username":"rhonda","grade":"5","grade_text":null,"department":"5"}}
Advertisement
Add Comment
Please, Sign In to add comment