Download the PHP package arjunkomath/crud without Composer
On this page you can find all versions of the php package arjunkomath/crud. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download arjunkomath/crud
More information about arjunkomath/crud
Files in arjunkomath/crud
Package crud
Short Description Generic PHP CRUD Library
License BSD-2-Clause BSD-3-Clause BSD-4-Clause
Informations about the package crud
PHP CRUD
A simple generic PHP CRUD library
Please note that this project is still in beta, it's not complete. There are more features to come.
Features
- Perform Create/Read/Update/Delete for you in just one line. :)
- In case, you don't feel like writing the views for all those, it will automatically generate the views also, and perform the corresponding operation.
- All views are generated using Bootstrap CSS.
Documentation
The documentation is hosted on Read the Docs: phpcrud.rtfd.org
Requirements
- [j4mie/idiorm] (https://github.com/j4mie/idiorm)
- MySQL
- And of course, PHP
Installation
Packagist
This library is available through Packagist with the vendor and package identifier of arjunkomath/crud
Please see the Packagist documentation for further information.
Configuration
Configue idiorm, you can read more about it here. You'll have to add the followng lines so that the CRUD class can access the database.
Code
Basic CRUD
Initialize the class
It has three functions as follows:
Read
This function can be used to read data, either the entire table data or you can read a row by its primary key. To read an entire table:
To read a row from a table by its primiary key:
All results are returned as array.
Save
This function can be used to save data to table, you can both create a new row or update an exsising entry. To create an entry: Specify the table name and then pass an array of arguments in such a format that array key represents the field name and value represents the field value. It will return the newly inserted id of the row.
To update an entry identified by its primiary key: You pass an additional paremeter id
that is the primary key value to the row to be updated. It will return the id of the row.
Delete
This function can be used to delete an entry from table.
It will return true
.
Find
This function can be used to find a row by field name and value.
It will return an array if the row exsists.
CRUD and Views
Initialize the class
It has four functions as follows:
Table
This function can be used to read data and display it in table format. To display an entire table:
It has an optional paramater, that lets you hide any unwanted fields. You can pass an array of field names, and it will automatically skip those fields from the view.
Read
This function can be used to read data from a row and display it in table format.
It has an optional paramater, that lets you hide any unwanted fields. You can pass an array of field names, and it will automatically skip those fields from the view.
Create
This function can be used to input data from the user and save it to database, the CRUD class will automatically generate the views and save the entry to database.
It has an optional paramater, that lets you hide any unwanted fields. You can pass an array of field names, and it will automatically skip those fields from the view. Note that no default values can be passed to these fields as of now, although it will be implemented in future.
Update
This function can be used to update an exsisting entry in the table, the CRUD class will automatically generate the views and update the entry in database.
It has an optional paramater, that lets you hide any unwanted fields. You can pass an array of field names, and it will automatically skip those fields from the view. Note that by default it will show the exsisting data saved in the row.
Thank you.