Properties

$sql_order

$sql_order

$_entity_factory

$_entity_factory : object

Holds an object of the entity factory, used for instantiating entities (obviously) Loaded by __construct() - so all descendants of RoxModelBase has access to it

Type

object — RoxEntityFactory

$_table_name

$_table_name : string

This is the table that the entity belongs to Entity implementations should obviously override this to be meaningful

Type

string

$_columns_cache

$_columns_cache : array

cache for list of columns

Type

array

$_primary_key

$_primary_key : string

The primary key of the table, most likely id Again, needs an override in the implementations

Type

string

$_has_loaded

$_has_loaded : bool

Determines whether a given entity has been loaded with data Does not show whether or not the entity has manage to init correctly!

Type

bool

$_validations

$_validations : array

contains validation errors after validation wiped on every validation

Type

array

$_validation_errors

$_validation_errors : array

contains validation errors after validation wiped on every validation

Type

array

$logged_in_member

$logged_in_member : object

stores the currently logged in member

Type

object

$_parameters

$_parameters

$_cache

$_cache

$_method_cache

$_method_cache

Methods

__construct()

__construct()

used to instantiate an RoxEntityFactory - other than that, just calls the parent

getLoggedInMember()

getLoggedInMember() : object|false

returns the currently logged in member

Returns

object|false

restoreLoggedInMember()

restoreLoggedInMember()

Restore session if memory cookie exists

bulkLookup()

bulkLookup(string $query_string, array $keynames) : array

This method fetches a bunch of rows from the database.

It has some funny mechanics, which you can usually just ignore.

Parameters

string $query_string
array $keynames
  • this will trigger the funny mechanics which sort the results into a hierarchic structure

Returns

array —

of rows (as objects)

bulkLookup_assoc()

bulkLookup_assoc(\unknown_type $query_string) : array

This is the same as the above bulkLookup, but the rows are associative arrays instead of objects.

Parameters

\unknown_type $query_string

Returns

array —

of rows (as associative arrays)

singleLookup()

singleLookup( $query_string)

Parameters

$query_string

singleLookup_assoc()

singleLookup_assoc( $query_string)

Parameters

$query_string

__call()

__call( $key,  $args)

Parameters

$key
$args

__get()

__get( $key)

Parameters

$key

__set()

__set( $key,  $value)

Parameters

$key
$value

refresh_get()

refresh_get( $key)

Parameters

$key

__toString()

__toString()

init()

init( $store, object $dao)

init function, replaces part of the __construct function

Parameters

$store
object $dao
  • data access object

getColumns()

getColumns() : array

returns an array of column names for the entity

Returns

array

getTableName()

getTableName() : string

returns the table name for the entity

Returns

string

getTableDescription()

getTableDescription() : array

returns an array describing the table of the entity

Throws

\EntityException

Returns

array

getPrimaryKey()

getPrimaryKey() : string|array|null

returns the name of the primary key for the entity return val is string if primary key is single field array if primary key spans fields, and null for no primary key

Returns

string|array|null

getPKValue()

getPKValue() : string

returns the value of the entity's primary key

Returns

string

isLoaded()

isLoaded() : bool

Lets the world know if it's been loaded with data properly or not

Returns

bool

findById()

findById(int $id) : mixed

load an object by it's id

Parameters

int $id
  • id of the group to load

Returns

mixed —

false or an object of class $this

findByWhere()

findByWhere(string $where) : mixed

load an object by a specified sql WHERE clause

Parameters

string $where
  • sql where clause to use

Returns

mixed —

false or $this

findByWhereMany()

findByWhereMany(string $where, integer $offset, integer $limit) : mixed

load an object by a specified sql WHERE clause

Parameters

string $where
  • sql where clause to use
integer $offset
  • offset to start from. Defaults to 0
integer $limit
  • how many results to limit the query to. Defaults to 0 (no limit)

Returns

mixed —

false or array or entities

findBySQL()

findBySQL(string $sql) : object

lets you load a single entity using an sql query should only be used in cases where the other find methods won't work

Parameters

string $sql

Returns

object

findBySQLMany()

findBySQLMany(string $sql) : array

lets you load an array of entities using an sql query should only be used in cases where the other find methods won't work

Parameters

string $sql

Returns

array

findAll()

findAll(integer $offset, integer $limit) : mixed

loads all rows from a table and returns them as an array of class $this

Parameters

integer $offset
  • offset to start from. Defaults to 0
integer $limit
  • how many results to limit the query to. Defaults to 0 (no limit)

Returns

mixed —

false or an array of objects of class $this

countAll()

countAll() : int

returns a count of all the rows in the entity's table

Returns

int

countWhere()

countWhere( $where) : int

returns a count of all the rows in the entity's table

Parameters

$where

Returns

int

loadFromArray()

loadFromArray(array $data) : object

Creates entities from a result set, using findById

Parameters

array $data
  • an array of data based on a DB lookup

Returns

object —
  • passes itself back

wipeEntity()

wipeEntity()

wipes an entity clean for data and resets the has_loaded flag

insert()

insert() : bool

Attempts to insert a row into the database, in the relevant table will build a SQL query based on the set variables in the object

Throws

\EntityException

Returns

bool

update()

update() : bool

Attempts to update a row into the database, in the relevant table will build a SQL query based on the set variables in the object

Throws

\EntityException

Returns

bool

delete()

delete() : bool

Delete a row from a table

Throws

\EntityException

Returns

bool

validateSelf()

validateSelf() : bool

Checks if the vars set in an entity are valid compares with the entities $_fields_array to make sure that values needed are present and the right type

Returns

bool

getValidationErrors()

getValidationErrors()

isPKSet()

isPKSet() : bool

checks whether all the primary key fields of an entity are set

Returns

bool

get_dao()

get_dao()

normally the $dao should be injected.

If it's not, this function creates a new one out of the blue..

createEntity()

createEntity() : object

calls the entity factory to create an entity, passes along any arguments

Returns

object

getDao()

getDao()

getMemoryCookie()

getMemoryCookie() : \array/boolean

Reads the contents of the memory cookie (for "stay logged in")

Returns

\array/boolean —

Contents of cookie or FALSE

setMemoryCookie()

setMemoryCookie( $id,  $seriesToken,  $authToken) : \array/boolean

Sets the contents of the memory cookie (for "stay logged in")

Parameters

$id
$seriesToken
$authToken

Returns

\array/boolean —

Contents of cookie or FALSE

get()

get( $key)

Parameters

$key

getValues()

getValues()

getWords()

getWords() : object

returns an instance of the MOD_words class

Returns

object

logWrite()

logWrite(string $string, string $type)

wrapper for calls to MOD_log::get->write()

Parameters

string $string
string $type

getLog()

getLog() : object

wrapper function for MOD_log::get()

Returns

object

getVersionInfo()

getVersionInfo() : string

returns the revision number saved in revision.txt

Returns

string

queryForEntity()

queryForEntity(string $query) : object|bool

runs an SQL query to find an entity, loads the current entity with data if it finds it

Parameters

string $query

Throws

\EntityException

Returns

object|bool

queryForEntities()

queryForEntities(string $query) : array

runs an SQL query to find several entities

Parameters

string $query

Throws

\EntityException

Returns

array

sqlCount()

sqlCount(string $query) : int

executes sql to count rows in a table

Parameters

string $query

Throws

\EntityException

Returns

int

loadEntities()

loadEntities(resource $result) : array

Creates entities from a result set, using findById

Parameters

resource $result
  • the DB resource result from the lookup

Returns

array

loadEntity()

loadEntity(array $data) : bool

Fills up an object with data

Parameters

array $data
  • associative array used to fill object with data

Returns

bool

validateField()

validateField(string $key, array $info) : bool

Checks a supplied key and value against the $_fields_array to check for validity

Parameters

string $key
  • the field to check
array $info
  • table description

Returns

bool

preparePKWhereString()

preparePKWhereString() : string|false

returns a string to serve as a where clause, uniquely specifying a row

Returns

string|false

parseDescribeResult()

parseDescribeResult(array $data) : array

parses an associative array result from a DESCRIBE TABLE call returns an array with more usable info

Parameters

array $data

Returns

array

getDataType()

getDataType(string $type) : array

returns the type of data and possible values if any values are only returned for enum and set

Parameters

string $type

Returns

array

performStrictValueCheck()

performStrictValueCheck( $value,  $field_info)

Parameters

$value
$field_info

checkDataType()

checkDataType( $value,  $datatype)

Parameters

$value
$datatype