PHP Classes
elePHPant
Icontem

Data Workings: Access database table records as objects

Recommend this page to a friend!
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2006-05-05 (10 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 414 All time: 6,114 This week: 1,109Up
Version License Categories
dataw 1.0The PHP LicenseDatabases
Description Author

This class can be used to access records of an SQL database table as objects.

It can access a SQL database table and retrieve its list columns so it can determine which fields need to be retrieved and stored to map record information to object variables and vice-versa.

It can insert new table records from values set to the respective object variables.

It can also retrieve or delete table records given the primary key value, assuming that the table only has one primary key field.

A changed object may also be saved back to the respective table record.

The class can also execute queries that retrieve multiple records. The queries may be sorted by given field. The range of records returned by the query may also be limited to a given range.

The class supports multiple databases relying on PEAR DB package.

Picture of Kevin Cadman
Name: Kevin Cadman <contact>
Classes: 2 packages by
Country: South Africa South Africa

Details
DataWorkings by Kevin Cadman. (kevin.cadman@gmail.com)

Last Updated - 22/05/2006.

A class used to interface with an SQL database. Variables within the class are mapped according to the result set returned. Functions such as insert(),update() and delete() are supported.

Features: automatic primary-key detection, advanced error-checking on queries, automatic pagination, multiple DB support (mySQL recommended) and table joins.

In short, one of the simplest database systems you'll ever find!

NOTE: This class relies upon PEAR's DB class. You will need a working DB connection setup via PEAR's DB class to use this class.

Valid functions:

setEscapeHTML() - Used if we want to escape HTML characters when returning our results.
setPageVarName() - Used if we want to change the 'paging' variable (defaultly DWp)
setResultsPerPage() - Sets number of results per page
getNumRows() - returns number of affected rows
setJoin() - used to join tables
pagingHTML() - outputs HTML for pagination
setOrder() - used to set ordering on tables
setClause() - used to set 'where' clauses in queries.
get() - a 'quick' method of retrieving results via the automatically-detected primary key
query() - used in conjunction with setClause() and fetch() to get results based on clauses.
fetch() - fetches the results from the array and converts them to active variables within the class
update() - generates and performs the update query on the table
delete() - generates and performs the delete query on the table
insert() - generates and performs the insert query on the table

I hope you find this class useful. I am avaiable on email for any questions, suggestions or complaints.
  Files folder image Files  
File Role Description
Plain text file dataclass.inc Class DataObject Class
Accessible without login Plain text file examples.php Example Example Usage
Accessible without login Plain text file system.inc Conf. System Configuration and Database Connection
Accessible without login Plain text file README Doc. Information

 Version Control Unique User Downloads Download Rankings  
 0%
Total:414
This week:0
All time:6,114
This week:1,109Up