Witam. Mam problem, a mianowicie insert dodaje mi dwa pola w bazie, choć powinien dodać jedno.

O to kod:

  1. <?php
  2. ini_set('error_reporting', E_ALL);;
  3. class garage
  4. {
  5. public $pdo ;
  6. public $temp ;
  7. public $player ;
  8. private $info = array() ;
  9. public function __construct($pdo, $temp, $player)
  10. {
  11. $this->build = $build;
  12. $this->_pdo = $pdo ;
  13. $this->_player = $player ;
  14. $this->_info = $info;
  15. if($_GET['go'] == 'build')
  16. {
  17. $this->build() ;
  18. }
  19. try
  20. {
  21. $dis_garage = $this->_pdo->prepare('SELECT * FROM garage WHERE id_user=?');
  22. $dis_garage -> bindValue(1, $this->_player->id);
  23. $dis_garage ->execute();
  24. $this->_info = $dis_garage -> fetch();
  25. $temp->assign("player_garage", $this->_info);
  26. }
  27. catch(PDOException $e)
  28. {
  29. $result = form_field('Błąd połączenia. Powód: ' . $e->getMessage(), 'error');
  30.  
  31. }
  32. $temp->display('garage.tpl');
  33.  
  34. }
  35.  
  36. public function build()
  37. {
  38. if($this->_player->garage == 0)
  39. {
  40. try
  41. {
  42. $db = $this->_pdo->prepare('INSERT INTO `garage` (id_user, level, cars, max_cars) VALUES(?, ?, ?, ?)');
  43. $db->execute(array($this->_player->id, 1, 0, 1));
  44. $db-> closeCursor();
  45. query('update users set garage=1 where id=?', array($this->_player->id), $this->_pdo);
  46. return true ;
  47.  
  48.  
  49. }
  50. catch(PDOException $e)
  51. {
  52. $result = form_field('Błąd połączenia. Powód: ' . $e->getMessage(), 'error');
  53. }
  54. }
  55. else
  56. {
  57. return false ;
  58. }
  59. }
  60.  
  61.  
  62. }
  63.  
  64. ?>


z góry dzięki ;-)