![]() |
NanoFramework 1.4.0
A tiny PHP Framework
|
Interface that the user can implement in order to create a new Model, based on a real ODBC. More...
Public Member Functions | |
findAll () | |
find (int $id) | |
insert (array $data) | |
update (int $id, array $data) | |
delete (int $id) | |
where (string $key, mixed $value) | |
getLastInsertedId () | |
validate (array $data, string $ruleset, array &$errors=[]) | |
Interface that the user can implement in order to create a new Model, based on a real ODBC.
This interface contains all the required functionalities needed for a new Model.
Definition at line 10 of file ModelInterface.php.
delete | ( | int | $id | ) |
find | ( | int | $id | ) |
Retrives the data with the given id or null
if it doesn't exist.
int | $id | the id of the data to retrive |
null
Implemented in Model.
findAll | ( | ) |
getLastInsertedId | ( | ) |
Gives the last id inserted in the table.
Implemented in Model.
insert | ( | array | $data | ) |
update | ( | int | $id, |
array | $data | ||
) |
Updates the table with new data.
int | $id | the id of the element to update |
array | $data | the new version of the data |
Implemented in Model.
validate | ( | array | $data, |
string | $ruleset, | ||
array & | $errors = [] |
||
) |
Validates the given data against a ruleset.
In order to use the model validator, one must first redefine the $validation
attribute in the class. That attribute is an associative array having a ruleset name as a key and an associative array describing the rules as a value.
Example of a valid validation rulesets:
array | $data | The data to validate as an associative array |
string | $ruleset | The name of the ruleset to use |
array | &$errors | An array where to store the error data if any |
Implemented in Model.
where | ( | string | $key, |
mixed | $value | ||
) |
Adds a criteria about the request.
string | $key | The key to filter |
mixed | $value | The value to keep |
Implemented in Model.