jDaoFactoryBase
in package
base class for all factory classes generated by the dao compiler.
Tags
Table of Contents
- $_conn : jDbConnection
- the database connector.
- $_DaoRecordClassName : string
- the class name of a dao record for this dao factory.
- $_daoSelector : string
- the selector of the dao, to be sent with events.
- $_deleteAfterEvent : mixed
- $_deleteBeforeEvent : mixed
- $_deleteByAfterEvent : mixed
- $_deleteByBeforeEvent : mixed
- $_fromClause : string
- the from clause you can reuse for a specific SELECT query.
- $_primaryTable : string
- the id of the primary table.
- $_selectClause : string
- the select clause you can reuse for a specific SELECT query.
- $_tables : array<string|int, mixed>
- informations on tables.
- $_whereClause : string
- the where clause you can reuse for a specific SELECT query.
- $falseValue : mixed
- $trueValue : mixed
- __construct() : mixed
- countAll() : int
- return the number of all records.
- countBy() : int
- return the number of records corresponding to the conditions stored into the jDaoConditions object.
- createRecord() : jDaoRecordBase
- creates a record object for the dao.
- deleteBy() : number
- delete all record corresponding to the conditions stored into the jDaoConditions object.
- findAll() : jDbResultSet
- return all records.
- findBy() : jDbResultSet
- return all record corresponding to the conditions stored into the jDaoConditions object.
- getPrimaryKeyNames() : array<string|int, mixed>
- list of id of primary properties.
- getPrimaryTable() : string
- getProperties() : array<string|int, mixed>
- informations on all properties.
- getTables() : array<string|int, mixed>
- insert() : int
- save a new record into the database if the dao record has an autoincrement key, its corresponding property is updated.
- update() : int
- save a modified record into the database.
- _callbackBool() : mixed
- a callback function for some array_map call in generated methods.
- _callbackQuote() : mixed
- a callback function for some array_map call in generated methods.
- _callbackQuoteBin() : mixed
- a callback function for some array_map call in generated methods.
- _getPkWhereClauseForNonSelect() : string
- create a WHERE clause with conditions on primary keys with given value. This method should be used for DELETE and UPDATE queries.
- _getPkWhereClauseForSelect() : string
- create a WHERE clause with conditions on primary keys with given value. This method should be used for SELECT queries. You haven't to escape values.
- _prepareValue() : mixed
- prepare the value ready to be used in a dynamic evaluation.
- finishInitResultSet() : mixed
- finish to initialise a record set. Could be redefined in child class to do additionnal processes.
Properties
$_conn
the database connector.
protected
jDbConnection
$_conn
$_DaoRecordClassName
the class name of a dao record for this dao factory.
protected
string
$_DaoRecordClassName
$_daoSelector
the selector of the dao, to be sent with events.
protected
string
$_daoSelector
$_deleteAfterEvent
protected
mixed
$_deleteAfterEvent
= alse
Tags
$_deleteBeforeEvent
protected
mixed
$_deleteBeforeEvent
= alse
Tags
$_deleteByAfterEvent
protected
mixed
$_deleteByAfterEvent
= alse
Tags
$_deleteByBeforeEvent
protected
mixed
$_deleteByBeforeEvent
= alse
Tags
$_fromClause
the from clause you can reuse for a specific SELECT query.
protected
string
$_fromClause
$_primaryTable
the id of the primary table.
protected
string
$_primaryTable
$_selectClause
the select clause you can reuse for a specific SELECT query.
protected
string
$_selectClause
$_tables
informations on tables.
protected
array<string|int, mixed>
$_tables
Keys of elements are the alias of the table. values are arrays like that :
array ( 'name' => ' the table alias', 'realname' => 'the real name of the table', 'pk' => array ( list of primary keys name ), 'fields' => array ( list of property name attached to this table ) )
$_whereClause
the where clause you can reuse for a specific SELECT query.
protected
string
$_whereClause
$falseValue
protected
mixed
$falseValue
= 0
Tags
$trueValue
protected
mixed
$trueValue
= 1
Tags
Methods
__construct()
public
__construct(jDbConnection $conn) : mixed
Parameters
- $conn : jDbConnection
-
the database connection
Return values
mixed —countAll()
return the number of all records.
public
countAll() : int
Return values
int —the count
countBy()
return the number of records corresponding to the conditions stored into the jDaoConditions object.
public
final countBy(jDaoConditions $searchcond[, null|mixed $distinct = null ]) : int
Parameters
- $searchcond : jDaoConditions
- $distinct : null|mixed = null
Tags
Return values
int —the count
createRecord()
creates a record object for the dao.
public
createRecord() : jDaoRecordBase
Return values
jDaoRecordBase —deleteBy()
delete all record corresponding to the conditions stored into the jDaoConditions object.
public
final deleteBy(jDaoConditions $searchcond) : number
Parameters
- $searchcond : jDaoConditions
Tags
Return values
number —of deleted rows
findAll()
return all records.
public
findAll() : jDbResultSet
Return values
jDbResultSet —findBy()
return all record corresponding to the conditions stored into the jDaoConditions object.
public
final findBy(jDaoConditions $searchcond, int $limitOffset[, int $limitCount = null ]) : jDbResultSet
you can limit the number of results by given an offset and a count.
Parameters
- $searchcond : jDaoConditions
- $limitOffset : int
- $limitCount : int = null
Return values
jDbResultSet —getPrimaryKeyNames()
list of id of primary properties.
public
getPrimaryKeyNames() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —list of properties name which contains primary keys
getPrimaryTable()
public
getPrimaryTable() : string
Tags
Return values
string —the id (alias or realname) of the primary table
getProperties()
informations on all properties.
public
getProperties() : array<string|int, mixed>
keys are property name, and values are an array like that :
array ( 'name' => 'name of property', 'fieldName' => 'name of fieldname', 'regExp' => NULL, // or the regular expression to test the value 'required' => true/false, 'isPK' => true/false, //says if it is a primary key 'isFK' => true/false, //says if it is a foreign key 'datatype' => '', // type of data : string 'unifiedType'=> '' // the corresponding unified type 'table' => 'grp', // alias of the table the property is attached to 'updatePattern' => '%s', 'insertPattern' => '%s', 'selectPattern' => '%s', 'sequenceName' => '', // name of the sequence when field is autoincrement 'maxlength' => NULL, // or a number 'minlength' => NULL, // or a number 'ofPrimaryTable' => true/false 'autoIncrement'=> true/false )
Tags
Return values
array<string|int, mixed> —informations on all properties
getTables()
public
getTables() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —informations on tables
insert()
save a new record into the database if the dao record has an autoincrement key, its corresponding property is updated.
public
abstract insert(jDaoRecordBase $record) : int
Parameters
- $record : jDaoRecordBase
-
the record to save
Return values
int —1 if success (the number of affected rows). False if the query has failed.
update()
save a modified record into the database.
public
abstract update(jDaoRecordBase $record) : int
Parameters
- $record : jDaoRecordBase
-
the record to save
Return values
int —1 if success (the number of affected rows). False if the query has failed.
_callbackBool()
a callback function for some array_map call in generated methods.
protected
_callbackBool(mixed $value) : mixed
Parameters
- $value : mixed
Return values
mixed —_callbackQuote()
a callback function for some array_map call in generated methods.
protected
_callbackQuote(mixed $value) : mixed
Parameters
- $value : mixed
Tags
Return values
mixed —_callbackQuoteBin()
a callback function for some array_map call in generated methods.
protected
_callbackQuoteBin(mixed $value) : mixed
Parameters
- $value : mixed
Tags
Return values
mixed —_getPkWhereClauseForNonSelect()
create a WHERE clause with conditions on primary keys with given value. This method should be used for DELETE and UPDATE queries.
protected
abstract _getPkWhereClauseForNonSelect(array<string|int, mixed> $pk) : string
Parameters
- $pk : array<string|int, mixed>
-
associated array : keys = primary key name, values : value of a primary key
Return values
string —a 'where' clause (WHERE mypk = 'myvalue' ...)
_getPkWhereClauseForSelect()
create a WHERE clause with conditions on primary keys with given value. This method should be used for SELECT queries. You haven't to escape values.
protected
abstract _getPkWhereClauseForSelect(array<string|int, mixed> $pk) : string
Parameters
- $pk : array<string|int, mixed>
-
associated array : keys = primary key name, values : value of a primary key
Return values
string —a 'where' clause (WHERE mypk = 'myvalue' ...)
_prepareValue()
prepare the value ready to be used in a dynamic evaluation.
protected
final _prepareValue(mixed $value, mixed $fieldType[, mixed $notNull = false ]) : mixed
Parameters
- $value : mixed
- $fieldType : mixed
- $notNull : mixed = false
Return values
mixed —finishInitResultSet()
finish to initialise a record set. Could be redefined in child class to do additionnal processes.
protected
finishInitResultSet(jDbResultSet $rs) : mixed
Parameters
- $rs : jDbResultSet
-
the record set