|All requests||>||database crud for each table||>||Request new recommendation||>||Featured requests||>||No recommendations|
by John Gould - 2 years ago (2017-10-21)
Package to analyze each table and create pdo crud for each
1. by Dave Smith - 2 years ago (2017-10-23) Reply
If I understand what you are looking for correctly, it can't be done. You are not able to perform most crud operations based solely on analyzing a schema.
You can have a method to create a record as long as there are firm rules where the data can be found. Since you would already have to know the schema to make the data available, a scan of the schema is redundant.
You can retrieve all columns with the * wildcard, so the schema is not needed. You also would not be able to relate tables based solely on an analysis of the tables.
Updating has the same issues as creating with the additional problem that an analysis of the table will not be any help with determining what records are updated in the WHERE clause.
Deleting a record has the problem with the WHERE clause as well.
found it. Take a look at this class https://www.phpclasses.org/package/10162-PHP-Generate-classes-to-access-MySQL-as-objects.html
1. by Dave Smith - 2 years ago (2017-10-25) Reply
Took a look at it, generates mysqli objects, not pdo, which should be fine for you as long as you don't mind mysqli.
It generates a class for each table which you have to instantiate into an object to work with that specific table. The create method introduces redundancy, however that can not be avoided. The update method can be tied into the last record fetched so it does not introduce redundancy. Both the update and delete methods have the ability to manage the WHERE clause.
I was not able to locate a method to manage table relations, it may be there and I just didn't see it. This limits your ability to retrieve and update multiple related tables, it looks like you will have to do it manually for each related table in your external code.
2. by Saro Carvello - 2 years ago (2017-11-06) in reply to comment 1 by Dave Smith Reply
"The update method can be tied into the last record fetched so it does not introduce redundancy". See the auto generated updateCurrent() method.
3. by Dave Smith - 2 years ago (2017-11-06) in reply to comment 2 by Saro Carvello Reply
Pretty sure I said it does NOT introduce redundancy. Are you saying it does?
4. by Saro Carvello - 2 years ago (2017-11-06) in reply to comment 3 by Dave Smith Reply
OK. I just said about updateCurrent()