public static function fromJson($json, Hydrator\HydratorInterface $hydrator = null) { if (is_string($json)) { $json = json_decode($json, true); } if (!is_array($json)) { throw new InvalidArgumentException('The provided specification must be a JSON-decodeable string, or an associative array'); } $description = new self(); if ($hydrator) { $description->setHydrator($hydrator); } $description->hydrate($json); return $description; }
/** * */ static function Get($id) { $sql = 'SELECT * FROM representative WHERE id = :id'; $properties = Database::Query($sql, ['id' => $id]); if (empty($properties)) { return null; } else { $item = new self(); $properties['id'] = (int) $properties['id']; $item->hydrate($properties); return $item; } }