@oddz: I don't want to bother you anymore. This will be my last post on this topic, I need to find another way for learning this without having to make 3423423 posts. :s I realise that, and I'm really sorry. You explanations however, have been precious for starting on this OOP thing.
The script returns no errors. However, all the data inserted on the db table is NULL. I don't know why.
Here is the pages that (I suppose) are the relevant ones):
ProcessINSERTdog.php
DogDAO.class.phpPHP Code:<?php
$id_vet=$_POST["listvets"];
$dogname=$_POST["txt_dogname"];
$dog = new Dog();
$vet = new Vet();
$dog->setVet($vet);
$vet->setId($id_vet);
$dogdao = new DogDAO();
$dogdao->insert($dog);
?>
PHP Code:class DogDAO extends DAOGeral {
public function insert(Dog $dog){
$stmt = $this->_dbh->prepare("INSERT INTO DOG (DOG_NAME, ID_VET) VALUES (?, ?)");
$stmt->bindParam(1, $dog->getDogName(), PDO::PARAM_STR );
$stmt->bindParam(2, $dog->getVet()->getId(), PDO::PARAM_INT);
$stmt->execute();
}
}
?>
Dog.class.php
PHP Code:class Site {
private $_id_dog;
private $_name_dog;
private $_vet;
public function setId( $id_dog ){
$this->_id_dog = $id_dog;
}
public function setDogName( $name_dog ) {
$this->_name_dog = $name_dog;
}
public function setVet(Vet $vet) {
$this->_vet = $vet;
}
public function getId(){
return $this->_id_dog;
}
public function getDogName(){
return $this->_name_dog;
}
public function getVet(){
return $this->_vet;
}
}
?>
Regards,
Márcio











Bookmarks