Advertisement
MadeCurler

Code Error

Nov 21st, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. //when I use......
  2.  
  3.  
  4. $found_user=User::find_user_by_id(2);                      
  5. echo $found_user['id'];
  6.  
  7. //with
  8.  
  9. public static function find_user_by_id ($id){
  10. $result_set= self::find_this_query("SELECT * FROM users WHERE id=$id");
  11.                        
  12. $found_user=mysqli_fetch_array($result_set);
  13. return $found_user;
  14.            
  15.         }
  16.  
  17. //I get a result id returned
  18.  
  19. //but when I use
  20.  
  21. $found_user=User::find_user_by_id(2);
  22.    
  23. $myUser=User::instantiate($found_user);
  24.  
  25. echo $myUser->id;
  26.  
  27.  
  28. //with
  29.  
  30. public static function instantiate($found_user){
  31.  
  32. $the_object=new self;
  33.  
  34. foreach ($found_user as $the_attribute => $value) {
  35. if($the_object->has_the_attribute($the_attribute)){
  36. $the_object->the_attribute=$value;
  37.  
  38.         }
  39.  
  40. //I get a blank browser
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement