Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Painless CRUD in PHP via AjaxCrud

DZone's Guide to

Painless CRUD in PHP via AjaxCrud

· Web Dev Zone
Free Resource

Discover how to focus on operators for Reactive Programming and how they are essential to react to data in your application.  Brought to you in partnership with Wakanda


I recently discovered an Ajax CRUD library which makes CRUD operations positively painless: AjaxCRUD

Its features include:

- displaying list in an inline-editable table
- generates a create form
- all operations (add,edit,delete) handled via ajax
- supports 1:many relations
- only 1 class to include!!

I highly recommend you try it out!

Here is the example code:

 

# the code for the class
include ('ajaxCRUD.class.php');

# this one line of code is how you implement the class

$tblCustomer = new ajaxCRUD("Customer",
"tblCustomer", "pkCustomerID");

# don't show the primary key in the table

$tblCustomer->omitPrimaryKey();

# my db fields all have prefixes;
# display headers as reasonable titles

$tblCustomer->displayAs("fldFName", "First");

$tblCustomer->displayAs("fldLName", "Last");

$tblCustomer->displayAs("fldPaysBy", "Pays By");

$tblCustomer->displayAs("fldDescription", "Customer Info");

# set the height for my textarea

$tblCustomer->setTextareaHeight('fldDescription', 100);

# define allowable fields for my dropdown fields


# (this can also be done for a pk/fk relationship)

$values = array("Cash", "Credit Card", "Paypal");

$tblCustomer->defineAllowableValues("fldPaysBy", $values);

# add the filter box (above the table)

$tblCustomer->addAjaxFilterBox("fldFName");

# actually show to the table

$tblCustomer->showTable();
 
 

 

Source: http://www.supermind.org/blog/998/painless-crud-in-php-via-ajaxcrud

Learn how divergent branches can appear in your repository and how to better understand why they are called “branches".  Brought to you in partnership with Wakanda

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}