public static function load($userId) { if (!is_int($userId)) { throw new Certificate_Exception(_Core_Exception::typeErrorMessage($userId, 'User id', 'integer')); } $sql = 'select * from users where id=' . $userId; $row = Core::getInstance()->db->selectRow($sql); return new _User_Model($row); }
/** * Добавление обьекта * * @param object $object * @param integer $id */ public static function add($object, $id) { if (!is_object($object)) { throw new _Core_Exception(_Core_Exception::typeErrorMessage($object, 'Object', 'object')); } if (is_null($id)) { throw new _Core_Exception('Object id cannot be null!'); } $self = self::getInstance(); $className = get_class($object); if ($self->get($className, $id) != null) { throw new _Core_Exception('Object instance of "' . $className . '" already exist !'); } if (!array_key_exists($className, $self->objects)) { $self->objects[$className] = array(); } $self->objects[$className][$id] = $object; }