O to kod:
<?php class garage { public $pdo ; public $temp ; public $player ; public function __construct($pdo, $temp, $player) { $this->build = $build; $this->_pdo = $pdo ; $this->_player = $player ; $this->_info = $info; if($_GET['go'] == 'build') { $this->build() ; } try { $dis_garage = $this->_pdo->prepare('SELECT * FROM garage WHERE id_user=?'); $dis_garage -> bindValue(1, $this->_player->id); $dis_garage ->execute(); $this->_info = $dis_garage -> fetch(); $temp->assign("player_garage", $this->_info); } catch(PDOException $e) { $result = form_field('Błąd połączenia. Powód: ' . $e->getMessage(), 'error'); } $temp->display('garage.tpl'); } public function build() { if($this->_player->garage == 0) { try { $db = $this->_pdo->prepare('INSERT INTO `garage` (id_user, level, cars, max_cars) VALUES(?, ?, ?, ?)'); $db-> closeCursor(); return true ; } catch(PDOException $e) { $result = form_field('Błąd połączenia. Powód: ' . $e->getMessage(), 'error'); } } else { return false ; } } } ?>
z góry dzięki ;-)