# \hhu\z\modelsCharactersModel

Model to interact with Characters-table.

## Summary

Methods
Properties
Constants
__construct()
load()
factory()
getCharactersForUser()
getCharactersForSeminaryCount()
getCharactersForSeminary()
getCharactersForSeminarySorted()
getCharactersForGroup()
getCharacterForUserAndSeminary()
getCharacterByUrl()
getCharacterById()
getCharactersWithRole()
getCharactersWithMostAchievements()
getXPRank()
getSuperiorCharacters()
getInferiorCharacters()
getCharactersSolvedQuest()
getCharactersUnsolvedQuest()
getCharactersSubmittedQuest()
getCharactersWithCharacterRole()
characterNameExists()
createCharacter()
editCharacter()
deleteCharacter()
No public properties found
No constants found
No protected methods found
$db
N/A
loadDriver()
connect()
getClassName()
loadModels()
No private properties found
N/A

File
  models/CharactersModel.inc
Package
  Default
Class hierarchy
  \nre\core\Model
  \nre\models\DatabaseModel
  \hhu\z\Model
  \hhu\z\models\CharactersModel

## Tags

author | Oliver Hanraths oliver.hanraths@uni-duesseldorf.de

## Properties

### $db

    $db : \nre\models\DatabaseDriver

Database connection

#### Type

\nre\models\DatabaseDriver

#

Inherited from
  \nre\models\DatabaseModel

## Tags

static |

## Methods

### __construct()

    __construct()

Construct a new CharactersModel.

TODO Catch exception

#

## Tags

None found

### 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

#

static

Inherited from
  \nre\core\Model

## Tags

None found

### factory()

    factory(string  $modelName)

Instantiate a Model (Factory Pattern).

#### Parameters

string | $modelName | Name of the Model to instantiate

#

static

Inherited from
  \nre\core\Model

## Tags

None found

### getCharactersForUser()

    getCharactersForUser(integer  $userId) : array

Get all characters for an user.

#### Parameters

integer | $userId | ID of the user

#### Returns

array —

Characters

#

## Tags

None found

### 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

#

## Tags

None found

### 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

#

## Tags

None found

### 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

#

## Tags

None found

### getCharactersForGroup()

    getCharactersForGroup(integer  $groupId) : array

Get Characters for a Character group.

#### Parameters

integer | $groupId | ID of the Character group

#### Returns

array —

Characters

#

## Tags

None found

### 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

#

## Tags

None found

### 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

#

## Tags

None found

### 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

#

## Tags

None found

### getCharactersWithRole()

    getCharactersWithRole(string  $characterrole) : array

Get Characters with the given Character role.

#### Parameters

string | $characterrole | Character role

#### Returns

array —

List of Characters

#

## Tags

None found

### 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

#

## Tags

None found

### 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

#

## Tags

None found

### 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

#

## Tags

None found

### 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

#

## Tags

None found

### 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

#

## Tags

None found

### 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

#

## Tags

None found

### 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

#

## Tags

None found

### 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

#

## Tags

None found

### 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

#

## Tags

None found

### 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

#

## Tags

None found

### 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

#

## Tags

None found

### deleteCharacter()

    deleteCharacter(integer  $characterId)

Delete a Character.

#### Parameters

integer | $characterId | ID of the Character to delete

#

## Tags

None found

### loadDriver()

    loadDriver(string  $driverName)

Load the database driver.

#### Parameters

string | $driverName | Name of the database driver

#### Throws

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

#

Inherited from
  \nre\models\DatabaseModel

## Tags

None found

### 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

#

Inherited from
  \nre\models\DatabaseModel

## Tags

None found

### 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

#

static

Inherited from
  \nre\core\Model

## Tags

None found

### loadModels()

    loadModels()

Load the Models of this Model.

#### Throws

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

#

Inherited from
  \nre\core\Model

## Tags

None found

### CharactersModel.inc