I need a PHP class and function which will allow me to save PHP data in the MySQL database without having to create any table ahead of time. It should work like this: 1. I will instantiate the class passing ($resource, $tableName) to the constructor, where $resource is a valid MySQL connection and $tableName is the name of a table. 2. I will call a function: insert($array) one time for each row of data. The $array will be an associative array of names and values. The function will save this in the database per the Detailed Specification below. DETAILED SPECIFICATION ====================== - During instantiation, the class must automatically perform a 'show columns' to introspect the database and see if the table already exists and what column names and types are already created. - During insertion, the insert() function will automatically expand the table as follows. Columns will be created with the same name as the array key, if the column does not already exist. Each value in the associated array goes to the column that corresponds to its array key. - Each column must be created and maintained using the most restrictive possible type for the data inserted so far; e.g. INTEGER, then DECIMAL, then VARCHAR, then LONGTEXT. That means an ALTER TABLE should be executed prior to inserting new data into a column to expand it to a less restrictive type if the original type would not accommodate the new data. - For testing, the coder must write a main() method which invokes the constructor and insert() methods described above, with some semi-random sample data. - The class may be instantiated again at a later time to add more data; therefore the table metadata must always be refreshed in the constructor.
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):
a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment.
b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request.
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
4) Proof of testing, in the form of screenshots and/or output logs and explanation of results.
* * *This broadcast message was sent to all bidders on Sunday Mar 14, 2010 12:21:11 PM:
PLEASE KEEP IT SIMPLE WITH THE FOLLOWING ASSUMPTIONS. THERE WILL NOT BE ANY MULTI-DIMENSIONAL ARRAYS REQUIREMENT. ONLY FLAT KEY/VALUE PAIRS. ALL KEYS WILL BE VALID TO USE AS IDENTIFIERS. ALL VALUES WILL BE VALID PHP STRINGS (NO ARRAYS OR OBJECTS AS VALUES).
## Platform
PHP