Database Table PHP Class
Back to home page | View demo
This PHP class, Database Table is designed to strip away all the tedious coding necessary to create, read, update and delete entries to/from a database table (CRUD). This class is rather robust and allows quite a bit of functionality (if you need it). However, a simple line of code will make all the features available for simple database work. Examples of where the efficiency of this program works are with keeping track of loans and other recorded financial data.
This class ultilizes AJAX to allow easy editing of the existing rows. It also allows you to form relationships via primary-foreign keys, so that you don't have to remember the keys of entries.
Finally, for longer lists within a table, this class uses paging capabilities so that you can sort through only a limited number of rows (say 30 to a page), allowing for quick page refresh
This class was designed to use in admin pages, specifically to allow administrators to easily edit content for a CMS. However, its functionality can expand well beyond that, if desired.
Combined into a easy-to-use class (so you don't need to toy around with function calls, javascript references, etc), you can now implement in seconds what once would take a skilled programmer days.
This demo assumes you all ready have a database table created.
For the purposes of demostration, I will include the below steps for creating three mySQL tables with sample data: The second two tables are to demonstrate the cababilities of the classes joining on a relationship. You only need to have one table to implement this class, however.
CREATE TABLE tblFAQ( pkFAQID INT PRIMARY KEY AUTO_INCREMENT, fldQuestion VARCHAR(150), fldAnswer TEXT, fldSort INT, fkCategoryID INT, fkUserID INT ) CREATE TABLE tblFAQCategory( pkCategoryID INT PRIMARY KEY AUTO_INCREMENT, fldName VARCHAR(150), fldSort INT ) CREATE TABLE tblUser( pkUserID INT PRIMARY KEY AUTO_INCREMENT, fldName VARCHAR(50) )
INSERT INTO tblFAQCategory (fldName) VALUES ("PHP FAQ");
INSERT INTO tblFAQCategory (fldName) VALUES ("Javascript FAQ");
INSERT INTO tblFAQCategory (fldName) VALUES ("AJAX FAQ");
INSERT INTO tblUser (fldName) VALUES ("Sean Dempsey");
INSERT INTO tblUser (fldName) VALUES ("Justin Rigby");
INSERT INTO tblUser (fldName) VALUES ("Melissa Abrami");
The above SQL creates an empty table of FAQ (frequently asked questions) and also a table with for the categories of those FAQ items. Also, I have included a user table, which really does not make sense in this context, but will further demonstrate the power of the class.
Ok. Anyway though ... onto the fun part. Let's now edit/add/delete random stuff...