DAO for dual SQL table

package salt\dao
inherited_from \salt\Base

 Methods

Return an accessor for retrieve the text of a field

COLUMN(mixed $format = NULL) : \salt\DAOConverter
InheritedStatic

Parameters

$format

mixed

(Optional, NULL) the format to use

Returns

\salt\DAOConverterConverter for display the column of field

Return an accessor for retrieve an input of a field

FORM(mixed $format = NULL) : \salt\DAOConverter
Inherited

Parameters

$format

mixed

(Optional, NULL) format to use

Returns

\salt\DAOConverterConverter for display the input of a field

Retrieve the Model object containing metadata about the object

MODEL(boolean $withLoad = TRUE) : \salt\Model
InheritedStatic

Parameters

$withLoad

boolean

(Optionnal, TRUE) if TRUE, initialize the model if not exists. Never use in normal usage, only for internal usage

Returns

\salt\Modelthe Model object

Return an accessor for retrieve the SQL text of a field

SQL(mixed $format = NULL) : \salt\DAOConverter
Inherited

Parameters

$format

mixed

(Optional, NULL) format to use

Returns

\salt\DAOConverterConverter for retrieve SQL field value

Return an accessor for retrieve a field value

VIEW(mixed $format = NULL) : \salt\DAOConverter
Inherited

Parameters

$format

mixed

(Optional, NULL) format to use

Returns

\salt\DAOConverterConverter for display the value of field

Construct a new Identifiable object

__construct() 
Inherited

Have to be called by child classes for having an internal ID

Return the value of field or extra field of object.

__get(string $fieldName) : mixed
Inherited

Can also return an _InternalFieldAccess if $fieldName is FORM or VIEW

Parameters

$fieldName

string

Returns

mixedthe value of the field

Set a field value

__set(string $fieldName, mixed $value) 
Inherited

Parameters

$fieldName

string

the field to change

$value

mixed

the value

Add an extra field on instance after object creation

addExtraField(string $extraField) 
Inherited

Parameters

$extraField

string

field name

Exceptions

\salt\SaltException if field name is a regular field

Check object state is not in forbidden states

checkNotState(integer|array<mixed,integer> $state, string $message = NULL
Inherited

Parameters

$state

integerarray<mixed,integer>

forbidden states for the object

$message

string

error message for exception

Exceptions

\salt\SaltException if the object is in one of the forbidden states

Check object state is in allowed states

checkState(integer|array<mixed,integer> $state) 
Inherited

Parameters

$state

integerarray<mixed,integer>

expected states for the object

Exceptions

\salt\SaltException if the object is not in one of the expected states

Return a generic DELETE query on object

deleteQuery() : \salt\DeleteQuery
InheritedStatic

Returns

\salt\DeleteQuerythe delete query

Retrieve an object by ID on a database

getById(\salt\DBHelper $db, mixed $id) : static | NULL
InheritedStatic

Parameters

$db

\salt\DBHelper

The database to search object

$id

mixed

a value of the id field

Returns

staticNULLthe first object with this id. All fields are loaded. Return NULL if no object found

Retrieve a list of object on a database

getByIds(\salt\DBHelper $DB, array<mixed,mixed> $ids) : array<mixed,static>
InheritedStatic

Parameters

$DB

\salt\DBHelper

database to search objects

$ids

array<mixed,mixed>

list of value to search

Returns

array<mixed,static>associative array : id => object

Retrieve a Field by field name

getField(string $fieldName, boolean $createIfNotExists = FALSE) : \salt\Field
Inherited

Parameters

$fieldName

string

field name registered with metadata() or extra field constructor parameter

$createIfNotExists

boolean

if TRUE, create extra field if not exists, throw SaltException otherwise

Returns

\salt\Field

Get the value of the ID field. The ID field is registered with ::registerId()

getId() : mixed
Inherited

Returns

mixedvalue of id field

Get the name of the ID field registered with ::registerId()

getIdField() : string
Inherited

Returns

stringfield name

Get the internal unique id

getInternalId() : integer
Inherited

Returns

integerUnique ID of an instance

Return all modified field since object creation

getModifiedFields() : array<mixed,mixed>
Inherited

Returns

array<mixed,mixed>fieldName => value

Create and return a new object of the same type

getNew(array<mixed,string> $extraFields = NULL) : static
Inherited

Parameters

$extraFields

array<mixed,string>

array of fieldName to add to the instance

Returns

static

Return the tablename registered with ::registerTableName()

getTableName(boolean $withEscape = TRUE) : string
Inherited

Parameters

$withEscape

boolean

(Optional, TRUE) FALSE for do not escape table name with backquotes

Returns

stringthe table name

doing some stuff after creating table

initAfterCreateTable(\salt\DBHelper $db) : array<mixed,static>
Inherited

Parameters

$db

\salt\DBHelper

database where table is created

Returns

array<mixed,static>objects to create in table

Check if object is deleted

isDeleted() : boolean
Inherited

Returns

booleanTRUE if the object have been deleted

Check object is loaded from a database

isLoaded() : boolean
Inherited

Returns

booleanTRUE if the object have been loaded for a database by PDO

Check object has been modified

isModified() : boolean
Inherited

Returns

booleanTRUE if the object have been modified

Check object is new : so, not loaded from a database

isNew() : boolean
Inherited

Returns

booleanTRUE if the object have been created with a new ...()

Check object is a readonly object

isReadonly() : boolean
Inherited

Returns

booleanTRUE if the object is readonly (Base::singleton() is a readonly object)

Return a SELECT query on object

query(string $withField = FALSE) : \salt\Query
InheritedStatic

Parameters

$withField

string

TRUE for retrieve all fields, FALSE otherwise

Returns

\salt\Querythe empty query object

Make the object readonly. All changes will throw an exception.

readonly() 
Inherited

Retrieve a singleton instance

singleton() : static
InheritedStatic

Returns

statica singleton instance of the object

Return a generic UPDATE query on object

updateQuery(\salt\Query $fromQuery = NULL) : \salt\UpdateQuery
InheritedStatic

Parameters

$fromQuery

\salt\Query

the query to use for update

Returns

\salt\UpdateQuerythe update query

Check a field exist

checkFieldExists(string $fieldName, boolean $forValue = FALSE, boolean $doNotThrowException = FALSE) : boolean
Inherited

Parameters

$fieldName

string

$forValue

boolean

also check field is loaded and value can be retrieve

$doNotThrowException

boolean

return FALSE if field does not exists instead of throwing exception

Exceptions

\salt\SaltException if field don't exists or is not loaded (if $forValue)

Returns

booleanTRUE if field exists

Initialize the class by calling metadata() (once by class) and setting default values (once by instance) if needed

initValues(array<mixed,string> $loadedFields = NULL, array<mixed,string> $extraFields = NULL, boolean $loadAsNew = FALSE
Inherited

Parameters

$loadedFields

array<mixed,string>

fields loaded by a query for this object

$extraFields

array<mixed,string>

fields to add to new instance only

$loadAsNew

boolean

if TRUE, the afterLoad() method set the state to NEW instead of LOADED

 Properties

 

All extra fields which are returned by a query and are not declared in metadata

$_saltExtraFields : array<mixed,mixed>

Default

array()
content array of extraFieldName => value
   

TRUE if object loaded from constructed Query API, which format date as timestamp

$_saltFromQueryAPI : boolean

Default

FALSE
 

Contains values initially loaded from database or for new object (not in database)

$_saltLoadValues : array<mixed,mixed>

Default

array()
content array of fieldName => value
 

models of dao class.

$_saltModels : \salt\Model

Default

NULL
Static
 

object by child class name. Used in ::singleton()

$_saltSingletons : \salt\Base

Default

array()
Static
 

Current object state : self::_SALT<em>STATE</em>*

$_saltState : integer

Default

self::_SALT_STATE_NONE
 

Modified values for object loaded from database

$_saltValues : array<mixed,mixed>

Default

array()
content array of fieldName => value
 

current instance id

$_salt_id : integer

Default

 

last instance id

$_salt_id_sequence : integer

Default

0
Static

 Constants

 

State of a deleted object

_SALT_STATE_DELETED = 40 
 

State of an object created by PDO but not populated yet, with dynamic columns initialization (we don't know columns at object creation)

_SALT_STATE_DYNAMIC_LOADING = 13 
 

State of an object created and populated by PDO fetch

_SALT_STATE_LOADED = 20 
 

State of an object created by PDO but not populated yet

_SALT_STATE_LOADING = 12 
 

State of a modified object after being loaded by PDO

_SALT_STATE_MODIFIED = 30 
 

State of a new created objet

_SALT_STATE_NEW = 10 
 

State of an object created by PDO but not populated yet. After populate, the object will be at NEW state

_SALT_STATE_NEW_LOADING = 11 
 

State of a not initialized objet

_SALT_STATE_NONE = 0 
 

A special state for objet singleton returned by singleton() function. Throw an exception if a setter is called

_SALT_STATE_READONLY = 50