I have to write a Dog Creator class. I initially wrote this code:

```
<?php 
class Dog
{
  private $id, $name, $size, $age;
  public function setId($id){
    $this->id = $id
  }
  public function setName($name){
    $this->name = $name;
  }
  public function setSize($size){
    $this->size = $size;
  }
  public function setAge($age){
    $this->age = $age;
  }
  public function getId(){
    return $this->id;
  }
  public function getName(){
    return $this->name;
  }
  public function getSize(){
    return $this->size;
  }
  public function getAge(){
    return $this->age;
  }
}

class DogMapper
{
  private $pdo;

  public function __construct(PDO $pdo){
    $this->pdo = $pdo;
  }

  public function insert(Dog $dog){
    if(/* my controls*/){
      $this->pdo->query(/*query to insert $dog to database*/);
      $dog->setId($this->pdo->lastInsertId);
      return true;
    }else{
      return false;
    }
  }

  // Other CRUD methods

}

?>

```

Then I wrote one class instead of two:

```
<?php 
class Dog
{
  private $id, $name, $size, $age, $pdo;

  public function __construct(PDO $pdo){
    $this->pdo = $pdo;
  }
  public function setName($name){
    $this->name = $name;
  }
  public function setSize($size){
    $this->size = $size;
  }
  public function setAge($age){
    $this->age = $age;
  }
  public function getId(){
    return $this->id;
  }
  public function getName(){
    return $this->name;
  }
  public function getSize(){
    return $this->size;
  }
  public function getAge(){
    return $this->age;
  }
  public function insert(Dog $dog){
    if(/* my controls*/){
      $this->pdo->query(/*query to insert $dog to database*/);
      $this->id = $this->pdo->lastInsertId;
      return true;
    }else{
      return false;
    }
  }
  // Other CRUD methods
}
?>

```

What is the better version? And what improvements can I make?
Furthermore, some people have told me that I should not always use the getter and setter but the constructor, in my case, should I use them? If I should not use them, why and how do I know when I have to use them and when not?