Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. public function query($query) {
  2. $this->last_query = $query;
  3. $resultado = mysqli_query($this->connection, $query);
  4. $this->confirm_query($resultado);
  5. return $resultado;
  6. }
  7.  
  8. private function confirm_query($result) {
  9. if ($result === FALSE) {
  10. print_r(mysqli_fetch_assoc($result));
  11. $output = "Error on query". mysqli_error($this->connection)."<br/>";
  12. $output .= "Last query : ".$this->last_query;
  13. die($output);
  14. }
  15. }
  16.  
  17. public function fetch_array($result_set){
  18.  
  19. return mysqli_fetch_array($result_set);
  20.  
  21. }
  22.  
  23. public static function find_by_id($id=0){
  24. global $database;
  25. $result_set = $database -> query("SELECT * FROM users WHERE id={$id}");
  26. $found = $database ->fetch_array($result_set);
  27. return $found;
  28. }
  29.  
  30. $result_set = User::find_by_id(1);
  31. $found_user = $database ->fetch_array($result_set);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement