I have the following PHP class:

```
class Dog  
{  
   var $name;  
   var $age;  
   var $gender;
}  

```

I have the following sql statement: 

```
$sql = 'Select NAME,VALUE from dog_Details where id = 1';  
$results = $this->db->query($sql);  
$dog = new Dog();
foreach($results as $result)  
{  
  $dog->$result->NAME = $result->VALUE;  //This fails
}  

```

PHP error: 

> 
> Object of class stdClass could not be converted to string
> 
> 
> 

Question:
How do I bind values dynamically from the result set?