<?php use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; /** * @Entity @Table(name="locations") */ class Location extends BaseDBO { /** * @Id @Column(type="integer") @GeneratedValue */ private $id; /** * @Column(type="string") */ public $name; /** * @Column(type="string") */ public $description; public static function GetLocations() { global $entityManager; $locs = $entityManager->getRepository('Location')->findAll(); return $locs; } public static function EchoLocations() { $locs = Location::GetLocations(); echo "<select id='locations' style='width: 400px' class='form-input content__main__form__series'>"; $str = '<option value="0"><Выберите локацию из списка></option>'; foreach ($locs as $loc) { $str .= "<option value='$loc->id'>$loc->name</option>"; } echo "$str</select>"; } public static function Add($name, $desc) { $loc = new Location(); $loc->name = $name; $loc->description = $desc; $loc->Save(); echo "Локация создана"; } public function getName(): string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } }