dev-master
9999999-devGeneric PHP CRUD Library
BSD-2-Clause BSD-4-Clause BSD-3-Clause
The Requires
by Arjun Komath
v0.1-beta
0.1.0.0-betaGeneric PHP CRUD Library
BSD-2-Clause BSD-4-Clause BSD-3-Clause
The Requires
by Arjun Komath
Generic PHP CRUD Library
A simple generic PHP CRUD library, (*2)
Please note that this project is still in *beta, it's not complete. There are more features to come.*, (*3)
The documentation is hosted on Read the Docs: phpcrud.rtfd.org, (*4)
This library is available through Packagist with the vendor and package identifier of arjunkomath/crud
Please see the Packagist documentation for further information., (*5)
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., (*6)
<?php ORM::configure('mysql:host=localhost;dbname=my_database'); ORM::configure('username', 'database_user'); ORM::configure('password', 'top_secret');
Initialize the class, (*7)
$this->crud = new CRUD\CRUD();
It has three functions as follows:, (*8)
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:, (*9)
$result = $this->crud->read('table_name');
To read a row from a table by its primiary key:, (*10)
$result = $this->crud->read('table_name','id');
All results are returned as array., (*11)
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., (*12)
$result = $this->crud->save('table_name', array ("column1" => "value1", "column2" => "value2"));
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., (*13)
$result = $this->crud->save('table_name', array ("column1" => "value1", "column2" => "value2"), 'id');
This function can be used to delete an entry from table., (*14)
$result = $this->crud->delete('table_name', 'id');
It will return true
., (*15)
This function can be used to find a row by field name and value., (*16)
$result = $this->crud->find('table_name', 'field_name', 'value');
It will return an array if the row exsists., (*17)
Initialize the class, (*18)
$this->crud = new CRUD\Admin();
It has four functions as follows:, (*19)
This function can be used to read data and display it in table format. To display an entire table:, (*20)
$this->crud->table('table_name');
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., (*21)
$this->crud->table('table_name', array ('field_name'));
This function can be used to read data from a row and display it in table format., (*22)
$this->crud->table('table_name', 'id');
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., (*23)
$this->crud->table('table_name', 'id', array ('field_name'));
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., (*24)
$this->crud->create('table_name');
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., (*25)
$this->crud->create('table_name', array ('field_name'));
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., (*26)
$this->crud->update('table_name', 'id');
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., (*27)
$this->crud->create('table_name', 'id', array ('field_name'));
Thank you., (*28)
Generic PHP CRUD Library
BSD-2-Clause BSD-4-Clause BSD-3-Clause
Generic PHP CRUD Library
BSD-2-Clause BSD-4-Clause BSD-3-Clause