Storing form data in more than one db table

Discussion in 'Developers' Forum' started by Croydon, Jun 19, 2012.

  1. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    I'm just at trying to implement this
    http://www.howtoforge.com/forums/showthread.php?t=57628

    I want to create separate database and db_user forms - that is no problem.
    But to keep things easy for unexperienced users I want to (mainly) maintain the current database editing form and make the new ones optional.
    My question is: Is it possible to store information from one form into separate db tables?

    To make things clearer:
    There are three db tables.
    - databases
    - database users
    - db <-> user link table

    When using the current simple database editing form after saving and before displaying the data have to be stored to / read from those three tables.
    In the form definition files and server module/plugins I found the possibility to only give one single table.
    Theoretically I could store the data in the second / third table by hand, but as far as I can see the datalog and therefor the server modules would not recognize those changes.
    Could you (till/falko) give me some hint on how to proceed here?

    Thank you.
     
    Last edited: Jun 19, 2012
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Not with the default functions of the form, but you can ovverride each function. see tform_actions class which to see which even functions can be overridden.

    Btw. I would still prefer if you implement i as direct user -> DB relationship and not with 3 tables, so that you have a users table and a db table and one user can access one or more databases. This woould fit into the form framework better, is simpler to understand for the user.

    This would only be the case if you use the wrong functions to from the db class to insert and update data into this table. If you use the datalogInsert(), datalogUpdate() and datalogDelete() functions to insert data to that table, then all data is mirrored to slave servers as well and you can create a event hook in a server side plugin.
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    Not with the default functions of the form, but you can ovverride each function. see tform_actions class which to see which even functions can be overridden.

    Btw. I would still prefer if you implement i as direct user -> DB relationship and not with 3 tables, so that you have a users table and a db table and one user can access one or more databases. This woould fit into the form framework better, is simpler to understand for the user.

    This would only be the case if you use the wrong functions to from the db class to insert and update data into this table. If you use the datalogInsert(), datalogUpdate() and datalogDelete() functions to insert data to that table, then all data is mirrored to slave servers as well and you can create a event hook in a server side plugin.
     
  4. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    I get your point but I think it is much more useful to have multiple users for one database than having multiple databases for each user.
    I know it is easier using phpmyadmin because you have a listing of all databases of the user, but I still believe it is lot more benefit having read-only user(s) to access a database.
    So if you want to have multiple databases for a user and multiple users for a database I think there is no way to manage this using only 2 tables, although it would fit better into the form framework. Don't you agree?
     

Share This Page