Download the PHP package yohancayres/crud-advanced without Composer
On this page you can find all versions of the php package yohancayres/crud-advanced. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yohancayres/crud-advanced
More information about yohancayres/crud-advanced
Files in yohancayres/crud-advanced
Package crud-advanced
Short Description This class is a Crud with advanced methods. Provides agility and productivity in development. Edit
License MIT
Homepage https://github.com/yohancayres/crud-advanced
Informations about the package crud-advanced
Crud-Advanced
This class is a Crud with advanced methods. Provides agility and productivity in development.
All the methods and a description about them will be listed below. All class Crud.class.php is documented.
Installation
Install Manually
You can install CrudAdanved manually
Install with Composer
You can install CrudAdanved with composer With command:
or adding in composer.json
Available Methods
Generic Methods
- _set($key, $value) - Set or change the value of an attribute;
- _get($key) - Get the value of an attribute;
- loadData(array $data) - Loads data from an array to object attributes;
- requiredParam(array $params) - Checks whether the required attribute exists;
- getParamArray(array $params) - Get an array of object attributes;
Databases Methods
- dbInsert() - Inserts the attributes of the object in the database;
- dbUpdateAll() - Refreshes all attributes in the database;
- dbUpdateAtts($atts) - Updates specific attributes in the database;
- dbUpdate($attr, $newvalue) - Defines and updates the value of an attribute in the database;
- dbUpdateIncrease($attr, $amount) - Updates an attribute by incrementing its value (this value can be negative);
- dbSearch($attr, $data) - Searches the database;
- dbRemove() - Removes a record from the database;
- dbCheckExists($attr) - Checks whether a record already exists;
- dbLoadData($values) - Loads all data from the database;
- dbLoadDataBy($attr, $values) - Loads all database data using an attribute defined by the first parameter;
- fetchById($id, $values) - Get database record;
- fetchRandom($values) - Gets a random record of the database;
- fetchAll($where, $loadAtts) - Get all records from the table;
Relationship
- hasOne($className, $thisAttName, $classAttName, $loadAtts)- Creates a one-to-one relationship;
- hasMany($className, $thisAttName, $classAttName, $loadAtts) - Creates a one-to-many relationship;
Examples
Connect to the Database
First of all, the application needs information to connect to the database
Using Crud
To create a class and use the Crud Methods, you need to extends Crud to your class.
Insert new user with dbInsert()
This method will insert all the attributes to the database. Be aware of the name of the attributes, they must be exactly the same as the fields in the database.
dbLoadDataBy()
This method will load attributes from database, making the search for the defined attribute.
Update some row with dbUpdateAll() or dbUpdateAtts()
This method needs the id attribute, you can get it through dbLoadDataBy();
Update directly
This method needs the id attribute, you can get it through dbLoadDataBy();