![]() |
|
Snippets |
|
This is a model function with a field named avatar_id, that links to the avatar table, id field, and allows you to set the id based on the name of the avatar.
static function getAvatarByName($name) { $query = new Doctrine_Query(); $query->select('a.id'); $query->from('Avatar a'); $query->where('name = ?', $name); $avatar = $query->execute(); return $avatar[0]; } public function setAvatarIdByName($name) { $avatar = AvatarTable::getAvatarByName($name); $this->setAvatarId($avatar->getId()); }