Recommend this page to a friend! |
Download .zip |
Info | View files (4) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2005-07-22 (11 years ago) | Not enough user ratings | Total: 797 | All time: 4,119 This week: 1,078 |
Version | License | Categories | ||||
mtac 1.0 | GNU General Publi... | PHP 5, Databases |
Description | Author | |||||||||||||
This class can be used to wrap the access to individual MySQL database table rows in class objects. |
|
MySQL Table Abstraction Class (MTAC) MTAC is a small class that provides consistent methods and encapsulates data for MySQL tables. Essentially MTAC defines an associative array from a database row without having to worry about fetching the data. For a data to be encapsulated it needs, at a bare minimum, two common table columns, name and id. Suppose, for example, that we have a table containing information about a user. We can instantiate the user data with the following snippet: $user = new mtac($db,"user","Frank Jones"); This will create a user object with the following properties: class mtac { var $table; var $db; var $d; } $table is the stored table name passed on instantiation. $db is the handle to a MySQL connection. $d is an associative array of the data returned by the MySQL server. Other than Id and Name the table can have any number of columns and those data are stored in the associative array $mtac->d. If I add more tables -- the code still works. The only stipulation is that each table must have two properties in common: Name and Id. The code figures out which table and column to select in the database based on the two parameters passed on initialization (table,id). This is a simple means for retriving data without worrying about the details of the transaction with the MySQL server. This software is Copyright (C) 2005 Nic Stevens, Seattle, WA, US. This software is licensed for use under the Gnu Public License (Please see the enclosed gpl.txt) |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
0% |
|
|