Page
class Page extends Table
Class Page
Properties
DebugTool | $debugTool | The debug tool used. | from Entity |
string | $shortName | Class short name. | from Entity |
bool | $exists | from Entity | |
int | $id | ||
string | $idField | from Entity | |
string | $nameField | from Entity | |
array | $newData | from Entity | |
array | $oldData | from Entity | |
string | $tableName | It is the name of the table. | from FlatTable |
string | $modelName | It's the name of the model associated with the table | from FlatTable |
string | $locked | This field can exist or not (added here to avoid scrutinizer "property not exists") | from Table |
string | $controller | ||
string | $title | ||
string | $description | ||
string | $menu | ||
string | $icon | ||
int | $active | ||
string | $plugin | ||
string | $inserted_date | ||
string | $updated_date |
Methods
Page constructor.
Returns the name of the identification field of the record. By default it will be name.
Returns the name of the main key field of the table (PK-Primary Key). By default it will be id.
Execute a magic method of the setField or getField style
Get the name of the table (with prefix)
Return an array with the current active record.
Execute a call to setTableStructure with an array containing 3 arrays with the fields, keys and default values for the table.
Save the structure of the table in a static array, so that it is available at all times.
A raw array is built with all the information available in the table, configuration files and code.
Return a list of fields and their table structure. Each final model that needed, must overwrite it.
Returns a new instance of the table with the requested record.
This method is private. Use getBy instead.
Do a search to a table.
Return the main part of the search SQL query.
Create a new table if it does not exist and it has been passed true as a parameter.
Perform a search of a record by the name, returning the id of the corresponding record, or '' if it is not found or does not have a name field.
Get an array with all data.
Get default value data for this valueData.
Save the data to a record if pass the test and returns true/false based on the result.
Details
at line 34
__construct(bool $create = true)
Page constructor.
in
Entity
at line 106
string
getId()
Return the value of id.
in
Entity
at line 116
string
getNameField()
Returns the name of the identification field of the record. By default it will be name.
in
Entity
at line 128
$this
setData(array $data)
Assign newData from $data.
in
Entity
at line 143
string
getIdField()
Returns the name of the main key field of the table (PK-Primary Key). By default it will be id.
in
Entity
at line 153
array
getData()
Return newData details.
in
Entity
at line 163
array
getOldData()
Return oldData details.
in
Entity
at line 175
$this
setOldData(array $data)
Assign oldData from an array.
in
Entity
at line 191
$this|mixed|null
__call(string $method, array $params)
Execute a magic method of the setField or getField style
in
Entity
at line 220
mixed
__get(string $propertyName)
Magic getter.
It allows access to a field of the record using the attribute. To access the name field, we should use $this->getName(), but thanks to this, we can also use $this->name.
in
Entity
at line 236
$this
__set(string $propertyName, mixed $propertyValue)
Magic setter.
Allows you to assign value to a field in the record using the attribute. To assign a value to the name field, we should use $this->setName('Pepe'), but thanks to this, we can also use $this->name='Pepe'.
in
Entity
at line 252
bool
__isset(string $propertyName)
Magic isset.
in
FlatTable
at line 61
SimpleTable
get(string $id)
Returns a new instance of the table with the requested record.
As a previous step, a getData of the current instance is made, so both will point to the same record. Makes a getData and returns a new instance of the model.
in
FlatTable
at line 80
private bool
getDataById(string $id)
This method is private. Use load instead.
Establishes a record as an active record. If found, return true and the $id will be in $this->id and the data in $this->newData. If it is not found, return false, and have not effect into the instance.
in
FlatTable
at line 102
string
getQuotedTableName(bool $usePrefix = true)
Get the name of the table (with prefix)
in
FlatTable
at line 111
newRecord(string|null $id = null)
Sets the active record in a new record.
Note that changes made to the current active record will be lost.
in
SimpleTable
at line 105
array
defaultData()
TODO: Undocummented.
in
FlatTable
at line 139
string
getTableName(bool $usePrefix = true)
Get the name of the table (with prefix)
in
FlatTable
at line 153
array
getDataArray(string $id = null)
Return an array with the current active record.
If an $id is indicated, it searches to change the active record before returning the value. Warning: If an $id is set, any unsaved data will be lost when searching for the new record.
in
FlatTable
at line 170
bool
load(string $id)
Establishes a record as an active record.
If found, the $id will be in $this->id and the data in $this->newData. If it is not found, $this->id will contain '' and $this->newData will contain the data by default.
in
FlatTable
at line 180
bool
save()
Saves the changes made to the active record.
in
FlatTable
at line 213
private bool
updateRecord(array $data)
Update the modified fields in the active record.
$data is an array of assignments of type field=value.
in
FlatTable
at line 239
private bool
insertRecord(array $values)
Insert a new record.
$fields is an array of fields and $values an array with the values for each field in the same order.
in
FlatTable
at line 281
bool
delete()
Deletes the active record.
in
SimpleTable
at line 54
setStructure()
Execute a call to setTableStructure with an array containing 3 arrays with the fields, keys and default values for the table.
The development will be more ambitious than what is defined.
Currently Table includes a single table, but the idea is to be able to relate tables to form complex data models.
in
SimpleTable
at line 67
protected
setTableStructure(string $table, array $structure)
Save the structure of the table in a static array, so that it is available at all times.
in
SimpleTable
at line 79
protected array
getStructureArray()
A raw array is built with all the information available in the table, configuration files and code.
in
SimpleTable
at line 95
array
getFieldsFromTable()
Return a list of fields and their table structure. Each final model that needed, must overwrite it.
in
SimpleTable
at line 124
bool
getBy(string $key, mixed $value)
Returns a new instance of the table with the requested record.
As a previous step, a getDataBy of the current instance is made, so both will point to the same record. Makes a getDataBy and returns a new instance of the model.
in
SimpleTable
at line 140
private bool
getDataBy(string $key, mixed $value)
This method is private. Use getBy instead.
Establishes a record as an active record. If found the pair $key-$value the data will be in $this->newData. If it is not found, $this->id will contain '' and $this->newData will contain the data by default.
in
SimpleTable
at line 161
array
getStructure()
Returns the structure of the normalized table
in
SimpleTable
at line 172
array
getAllRecords()
Get an array with all data in table.
WARNING: This could be dangerous with a big table.
in
SimpleTable
at line 183
int
countAllRecords()
Count all registers in table.
in
SimpleTable
at line 198
array
getAllRecordsPaged(int $offset = 0)
Get an array with all data per page.
in
SimpleTable
at line 216
array
search(string $query, array $columns = [], int $offset = 0, string $order =
'')
Do a search to a table.
Returns the result per page.
in
SimpleTable
at line 234
string
searchQuery(string $query, array $columns = [])
Return the main part of the search SQL query.
in
SimpleTable
at line 268
int
searchCount(string $query, array $columns = [])
Do a search to a table.
Returns the result per page.
in Table
at line 52
checkStructure(bool $create = false)
Create a new table if it does not exist and it has been passed true as a parameter.
This should check if there are differences between the defined in dbStructure and the physical table, correcting the differences if true is passed as parameter.
in
Table
at line 68
string
getIdByName(string $name)
Perform a search of a record by the name, returning the id of the corresponding record, or '' if it is not found or does not have a name field.
in
Table
at line 94
array
getAllRecordsBy(string $key, mixed $value, string $comparison = '=',
string $orderBy = '')
Get an array with all data.
in
Table
at line 119
array
getIndexesFromTable()
Return a list of key indexes.
Each final model that needed, must overwrite it.
TODO: Why "*FromTable()" need to be overwrited on final model? Is not from model definition.
in
Table
at line 130
array
getDefaultValues()
Return a list of default values.
Each final model that needed, must overwrite it.
in
Table
at line 146
private bool|false|int|string
getDefaultValue(array $valueData)
Get default value data for this valueData.
in
Table
at line 188
array
getChecksFromTable()
TODO: Undocumented
in
Table
at line 200
bool
saveRecord(array $data)
Save the data to a record if pass the test and returns true/false based on the result.
in
Table
at line 215
protected bool
testData($data)
TODO: Undocumented
in
Table
at line 266
protected bool
saveData(array $data)
Try to save the data and return true/false based on the result.