PHP Classes

database crud for each table: Package to analyze each table and create pdo crud for each

Recommend this page to a friend!
  All requests RSS feed  >  database crud for each table  >  Request new recommendation  >  A request is featured when there is no good recommended package on the site when it is posted. Featured requests  >  No recommendations No recommendations  

database crud for each table

Edit

Picture of John Gould by John Gould - 6 years ago (2017-10-21)

Package to analyze each table and create pdo crud for each

This request is clear and relevant.
This request is not clear or is not relevant.

+2

Package to analyze each table and create pdo crud for each

  • 1 Clarification request
  • 1. Picture of Dave Smith by Dave Smith - 6 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.

    Ask clarification

    1 Recommendation

    MySQL Class Generator: Generate classes to access MySQL as objects

    This recommendation solves the problem.
    This recommendation does not solve the problem.

    0

    Picture of John Gould by John Gould Reputation 0 - 6 years ago (2017-10-23) Comment

    found it. Take a look at this class https://www.phpclasses.org/package/10162-PHP-Generate-classes-to-access-MySQL-as-objects.html

    • 5 Comments
    • 1. Picture of Dave Smith by Dave Smith - 6 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. Picture of Saro Carvello by Saro Carvello package author package author - 6 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. Picture of Dave Smith by Dave Smith - 6 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. Picture of Saro Carvello by Saro Carvello package author package author - 6 years ago (2017-11-06) in reply to comment 3 by Dave Smith Reply

      OK. I just said about updateCurrent()

    • 5. Picture of Saro Carvello by Saro Carvello package author package author - 3 years ago (2020-09-17) in reply to comment 1 by Dave Smith Reply

      you: "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"

      Did you know about the "single responsibility principle"? Each generated class has a single responsibility: to manage CRUD operations against a single table.


    Recommend package
    : 
    :