예제 #1
0
 /**
  * @param int $userId
  * @param ReadableRole $role
  * @return Role
  * @throws InsertRoleException
  * @throws \Exception
  */
 public function saveRole($userId, ReadableRole $role)
 {
     MDataType::mustBeInt($userId);
     $id = (int) $this->save($role);
     $sql = "CALL mt_user_save_role(?,?);";
     $query = new MPDOQuery($sql, $this->connection);
     $query->bindValue($userId);
     $query->bindValue($id);
     $queryResult = $query->exec();
     if ($queryResult == false) {
         throw new InsertRoleException($query->getLastError());
     }
 }
예제 #2
0
 /**
  * @param int $i
  * @param null|mixed $defaultValue
  * @return mixed|null
  */
 public function getValue($i, $defaultValue = null)
 {
     MDataType::mustBeInt($i);
     if ($i >= $this->count()) {
         $exception = new \OutOfBoundsException();
         throw $exception;
     }
     $value = $this->list[$i];
     if (is_null($value) === true && is_null($defaultValue) === false) {
         $value = $defaultValue;
     }
     return $value;
 }