Witam. Mam problem, a mianowicie insert dodaje mi dwa pola w bazie, choć powinien dodać jedno.
O to kod:
<?php
ini_set('error_reporting', E_ALL
);; class garage
{
public $pdo ;
public $temp ;
public $player ;
private $info = array() ; 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->execute(array($this->_player
->id, 1
, 0
, 1
)); $db-> closeCursor();
query
('update users set garage=1 where id=?', array($this->_player
->id), $this->_pdo
); 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 ;-)