public function __construct(\PDO $db, $id = null)
{
$this->db = $db;
$this->logger = new \Psr\Log\NullLogger();
// If $data is an integer, then it is assumed by the primary key
// of an existing record in the database.
if (is_int($id) || ctype_digit($id)) {
$this->data[static::PRIMARY_KEY_NAME] = $id;
$this->synchronise();
} else {
if (is_null($id)) {
$this->data = [];
} else {
throw new Exception\InvalidArgumentException('Invalid argument type.');
}
}
}