FlatTable
class FlatTable extends Entity
Class SimpleTable has all the basic methods to access and manipulate information, but without modifying its structure.
Properties
DebugTool | $debugTool | The debug tool used. | from Entity |
string | $shortName | Class short name. | from Entity |
bool | $exists | from Entity | |
string | $id | from Entity | |
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. | |
string | $modelName | It's the name of the model associated with the table |
Methods
Build a Table model. $table is the name of the table in the database.
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
Returns a new instance of the table with the requested record.
This method is private. Use load instead.
Get the name of the table (with prefix)
Sets the active record in a new record.
TODO: Undocummented.
Get the name of the table (with prefix)
Return an array with the current active record.
Establishes a record as an active record.
Saves the changes made to the active record.
Update the modified fields in the active record.
Insert a new record.
Deletes the active record.
Details
at line 41
__construct(string $tableName, array $params = [])
Build a Table model. $table is the name of the table in the database.
$params is a parameters array: - create is true if the table is to be created if it does not exist (false by default) - idField is the name of the primary key (default id) - nameField is the name of the descriptive field (name by default)
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.
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.
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.
at line 102
string
getQuotedTableName(bool $usePrefix = true)
Get the name of the table (with prefix)
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.
at line 127
array
defaultData()
TODO: Undocummented.
at line 139
string
getTableName(bool $usePrefix = true)
Get the name of the table (with prefix)
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.
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.
at line 180
bool
save()
Saves the changes made to the active record.
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.
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.
at line 281
bool
delete()
Deletes the active record.