Skip to content

Instantly share code, notes, and snippets.

@jasongrimes
Created January 29, 2012 13:47
Show Gist options
  • Save jasongrimes/1698902 to your computer and use it in GitHub Desktop.
Save jasongrimes/1698902 to your computer and use it in GitHub Desktop.
Album entity for extending Akrabat's ZF tutorial to use Doctrine
<?php
namespace Album\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* A music album.
*
* @ORM\Entity
* @ORM\Table(name="album")
* @property string $artist
* @property string $title
* @property int $id
*/
class Album {
/**
* @ORM\Id
* @ORM\Column(type="integer");
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string")
*/
protected $artist;
/**
* @ORM\Column(type="string")
*/
protected $title;
/**
* Magic getter to expose protected properties.
*
* @param string $property
* @return mixed
*/
public function __get($property) {
return $this->$property;
}
/**
* Magic setter to save protected properties.
*
* @param string $property
* @param mixed $value
*/
public function __set($property, $value) {
$this->$property = $value;
}
/**
* Convert the object to an array.
*
* @return array
*/
public function toArray() {
return get_object_vars($this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment