Properties

$db

$db : \nre\models\DatabaseDriver

Database connection

Type

\nre\models\DatabaseDriver

Methods

__construct()

__construct() 

Construct a new CharactersModel.

TODO Catch exception

load()

load(string  $modelName) 

Load the class of a Model.

Parameters

string $modelName

Name of the Model to load

Throws

\nre\exceptions\ModelNotFoundException
\nre\exceptions\ModelNotValidException

factory()

factory(string  $modelName) 

Instantiate a Model (Factory Pattern).

Parameters

string $modelName

Name of the Model to instantiate

getCharactersForUser()

getCharactersForUser(integer  $userId) : array

Get all characters for an user.

Parameters

integer $userId

ID of the user

Returns

array —

Characters

getCharactersForSeminaryCount()

getCharactersForSeminaryCount(integer  $seminaryId, string  $charactername = null) : integer

Get count of Characters for a Seminary.

Parameters

integer $seminaryId

ID of the Seminary

string $charactername

Only get Characters with the given name (optional)

Returns

integer —

Count of Characters

getCharactersForSeminary()

getCharactersForSeminary(integer  $seminaryId, boolean  $onlyWithRole = false) : array

Get Characters for a Seminary.

Parameters

integer $seminaryId

ID of the Seminary

boolean $onlyWithRole

Only Characters that have at least one role assigned (optional)

Returns

array —

Characters

getCharactersForSeminarySorted()

getCharactersForSeminarySorted(integer  $seminaryId, string  $sort, string  $charactername = '', integer  $limit = null, integer  $offset) : array

Get Characters for a Seminary sorted and optionally limited.

Parameters

integer $seminaryId

ID of the Seminary

string $sort

Field to sort by

string $charactername

Only get Characters with the given name (optional)

integer $limit

Limit amount of Characters (optional)

integer $offset

Offset (optional)

Returns

array —

Characters

getCharactersForGroup()

getCharactersForGroup(integer  $groupId) : array

Get Characters for a Character group.

Parameters

integer $groupId

ID of the Character group

Returns

array —

Characters

getCharacterForUserAndSeminary()

getCharacterForUserAndSeminary(integer  $userId, integer  $seminaryId) : array

Get the character of a user for a Seminary.

Parameters

integer $userId

ID of the user

integer $seminaryId

ID of the Seminary

Throws

\nre\exceptions\IdNotFoundException

Returns

array —

Character data

getCharacterByUrl()

getCharacterByUrl(integer  $seminaryId, string  $characterUrl) : array

Get a Character by its Url.

Parameters

integer $seminaryId

ID of the Seminary

string $characterUrl

URL-name of the Character

Throws

\nre\exceptions\IdNotFoundException

Returns

array —

Character data

getCharacterById()

getCharacterById(string  $characterId) : array

Get a Character by its Id.

Parameters

string $characterId

ID of the Character

Throws

\nre\exceptions\IdNotFoundException

Returns

array —

Character data

getCharactersWithRole()

getCharactersWithRole(string  $characterrole) : array

Get Characters with the given Character role.

Parameters

string $characterrole

Character role

Returns

array —

List of Characters

getCharactersWithMostAchievements()

getCharactersWithMostAchievements(integer  $seminaryId,   $count, boolean  $alsoWithDeadline = true) : array

Get Characters with the most amount of Achievements.

Parameters

integer $seminaryId

ID of Seminary

$count
boolean $alsoWithDeadline

Include Achievements with deadline (optional)

Returns

array —

List of Characters

getXPRank()

getXPRank(integer  $seminaryId, integer  $xps) : integer

Get the rank of a XP-value of a Character.

Parameters

integer $seminaryId

ID of Seminary

integer $xps

XP-value to get rank for

Returns

integer —

Rank of XP-value

getSuperiorCharacters()

getSuperiorCharacters(integer  $seminaryId, integer  $xps, integer  $count) : array

Get the superior $count Characters in the ranking.

Parameters

integer $seminaryId

ID of Seminary

integer $xps

XP-value of Character

integer $count

Count of Characters to determine

Returns

array —

List of superior Characters

getInferiorCharacters()

getInferiorCharacters(integer  $seminaryId,   $characterId, integer  $xps, integer  $count) : array

Get the inferior $count Characters in the ranking.

Parameters

integer $seminaryId

ID of Seminary

$characterId
integer $xps

XP-value of Character

integer $count

Count of Characters to determine

Returns

array —

List of inferior Characters

getCharactersSolvedQuest()

getCharactersSolvedQuest(integer  $questId) : array

Get Characters that solved a Quest.

Parameters

integer $questId

ID of Quest to get Characters for

Returns

array —

Characters data

getCharactersUnsolvedQuest()

getCharactersUnsolvedQuest(integer  $questId) : array

Get Characters that did not solv a Quest.

Parameters

integer $questId

ID of Quest to get Characters for

Returns

array —

Characters data

getCharactersSubmittedQuest()

getCharactersSubmittedQuest(integer  $questId) : array

Get Characters that sent a submission for a Quest.

Parameters

integer $questId

ID of Quest to get Characters for

Returns

array —

Characters data

getCharactersWithCharacterRole()

getCharactersWithCharacterRole(integer  $seminaryId, string  $characterrole) : array

Get Characters with the given Character role.

Parameters

integer $seminaryId

ID of Seminary

string $characterrole

Character role

Returns

array —

List of users

characterNameExists()

characterNameExists(string  $name, integer  $characterId = null) : boolean

Check if a Character name already exists.

Parameters

string $name

Character name to check

integer $characterId

Do not check this ID (for editing)

Returns

boolean —

Whether Character name exists or not

createCharacter()

createCharacter(integer  $userId, integer  $charactertypeId, string  $characterName) : integer

Create a new Character.

Parameters

integer $userId

User-ID that creates the new character

integer $charactertypeId

ID of type of new Character

string $characterName

Name for the new Character

Returns

integer —

ID of Character

editCharacter()

editCharacter(integer  $characterId, integer  $charactertypeId, string  $characterName) 

Edit a new Character.

Parameters

integer $characterId

ID of the Character to edit

integer $charactertypeId

ID of new type of Character

string $characterName

New name for Character

deleteCharacter()

deleteCharacter(integer  $characterId) 

Delete a Character.

Parameters

integer $characterId

ID of the Character to delete

loadDriver()

loadDriver(string  $driverName) 

Load the database driver.

Parameters

string $driverName

Name of the database driver

Throws

\nre\exceptions\DriverNotFoundException
\nre\exceptions\DriverNotValidException

connect()

connect(string  $driverName, array  $config) 

Establish a connection to the database.

Parameters

string $driverName

Name of the database driver

array $config

Connection settings

Throws

\nre\exceptions\DatamodelException

getClassName()

getClassName(string  $modelName) : string

Determine the classname for the given Model name.

Parameters

string $modelName

Model name to get classname of

Returns

string —

Classname fore the Model name

loadModels()

loadModels() 

Load the Models of this Model.

Throws

\nre\exceptions\DatamodelException
\nre\exceptions\DriverNotFoundException
\nre\exceptions\DriverNotValidException
\nre\exceptions\ModelNotValidException
\nre\exceptions\ModelNotFoundException