OOP page: Where to put update, insert, delete

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jn

    OOP page: Where to put update, insert, delete

    I have a page that shows info from MySQL. It is for an online education
    site. It uses different classes arranged in a hierarchy. Each lesson is
    roughly laid out like this:

    Lesson
    |-Intro
    |
    |-Section
    | |-Procedure
    | |-text, video, images
    |
    |-Section
    | |-Procedure
    | |-text, video, images
    |
    |-Summary

    I have all the classes working properly for displaying info from the
    database. Now I am building the admin site.

    Where should I put the update/insert/delete code? Would those go inside the
    classes? Should I use the lesson object when doing the maintenance? Or,
    should I just have a separate page that handles the database stuff and only
    use the objects to display the data from the database?

    I am sure many of you have done this sort of thing before. Any help would be
    appreciated!


  • Kevin Thorpe

    #2
    Re: OOP page: Where to put update, insert, delete

    jn wrote:
    [color=blue]
    > I have a page that shows info from MySQL. It is for an online education
    > site. It uses different classes arranged in a hierarchy. Each lesson is
    > roughly laid out like this:
    >
    > Lesson
    > |-Intro
    > |
    > |-Section
    > | |-Procedure
    > | |-text, video, images
    > |
    > |-Section
    > | |-Procedure
    > | |-text, video, images
    > |
    > |-Summary
    >
    > I have all the classes working properly for displaying info from the
    > database. Now I am building the admin site.
    >
    > Where should I put the update/insert/delete code? Would those go inside the
    > classes? Should I use the lesson object when doing the maintenance? Or,
    > should I just have a separate page that handles the database stuff and only
    > use the objects to display the data from the database?
    >
    > I am sure many of you have done this sort of thing before. Any help would be
    > appreciated!
    >[/color]
    Strictly speaking each class should have a method to save itself. The
    save method for the lesson would then call save for each section which
    would call save on each procedure etc.

    Having said that you might not want the save code available for every
    user as a security precaution. If there is only one admin web page that
    the save goes on then I tend to include the validation and save code on
    that so I know it's not available to the main website.



    Comment

    • Jochen Daum

      #3
      Re: OOP page: Where to put update, insert, delete

      Hi jn!

      On Mon, 20 Oct 2003 11:51:01 GMT, "jn" <jsumner1@cfl.r r.com> wrote:

      (...)
      [color=blue]
      >I have all the classes working properly for displaying info from the
      >database. Now I am building the admin site.
      >
      >Where should I put the update/insert/delete code? Would those go inside the
      >classes? Should I use the lesson object when doing the maintenance? Or,
      >should I just have a separate page that handles the database stuff and only
      >use the objects to display the data from the database?
      >
      >I am sure many of you have done this sort of thing before. Any help would be
      >appreciated![/color]

      Yes, it has been done 100 times. I have implemented a class set that
      handles this from one file, with a Strategy pattern.

      Have a look at the thing in the signature.

      HTH, Jochen
      [color=blue]
      >[/color]

      --
      Jochen Daum - CANS Ltd.
      PHP DB Edit Toolkit -- PHP scripts for building
      database editing interfaces.
      Download PHP DB Edit Toolkit for free. PHP DB Edit Toolkit is a set of PHP classes makes the generation of database edit interfaces easier and faster. The main class builds tabular and form views based on a data dictionary and takes over handling of insert/update/delete and user input.

      Comment

      • jn

        #4
        Re: OOP page: Where to put update, insert, delete


        "Jochen Daum" <jochen.daum@ca ns.co.nz> wrote in message
        news:50c8pvo5hr 03qoet39ak9ojst f3jllv5am@4ax.c om...[color=blue]
        > Hi jn!
        >
        > On Mon, 20 Oct 2003 11:51:01 GMT, "jn" <jsumner1@cfl.r r.com> wrote:
        >
        > (...)
        >[color=green]
        > >I have all the classes working properly for displaying info from the
        > >database. Now I am building the admin site.
        > >
        > >Where should I put the update/insert/delete code? Would those go inside[/color][/color]
        the[color=blue][color=green]
        > >classes? Should I use the lesson object when doing the maintenance? Or,
        > >should I just have a separate page that handles the database stuff and[/color][/color]
        only[color=blue][color=green]
        > >use the objects to display the data from the database?
        > >
        > >I am sure many of you have done this sort of thing before. Any help would[/color][/color]
        be[color=blue][color=green]
        > >appreciated![/color]
        >
        > Yes, it has been done 100 times. I have implemented a class set that
        > handles this from one file, with a Strategy pattern.
        >
        > Have a look at the thing in the signature.
        >
        > HTH, Jochen
        >[color=green]
        > >[/color]
        >
        > --
        > Jochen Daum - CANS Ltd.
        > PHP DB Edit Toolkit -- PHP scripts for building
        > database editing interfaces.
        > http://sourceforge.net/projects/phpdbedittk/
        >[/color]

        That thing's pretty cool (and complicated) :)


        Comment

        • jn

          #5
          Re: OOP page: Where to put update, insert, delete


          "Kevin Thorpe" <kevin@pricetra k.com> wrote in message
          news:3f93d037$0 $384$afc38c87@n ews.easynet.co. uk...[color=blue]
          > jn wrote:
          >[color=green]
          > > I have a page that shows info from MySQL. It is for an online education
          > > site. It uses different classes arranged in a hierarchy. Each lesson is
          > > roughly laid out like this:
          > >
          > > Lesson
          > > |-Intro
          > > |
          > > |-Section
          > > | |-Procedure
          > > | |-text, video, images
          > > |
          > > |-Section
          > > | |-Procedure
          > > | |-text, video, images
          > > |
          > > |-Summary
          > >
          > > I have all the classes working properly for displaying info from the
          > > database. Now I am building the admin site.
          > >
          > > Where should I put the update/insert/delete code? Would those go inside[/color][/color]
          the[color=blue][color=green]
          > > classes? Should I use the lesson object when doing the maintenance? Or,
          > > should I just have a separate page that handles the database stuff and[/color][/color]
          only[color=blue][color=green]
          > > use the objects to display the data from the database?
          > >
          > > I am sure many of you have done this sort of thing before. Any help[/color][/color]
          would be[color=blue][color=green]
          > > appreciated!
          > >[/color]
          > Strictly speaking each class should have a method to save itself. The
          > save method for the lesson would then call save for each section which
          > would call save on each procedure etc.
          >
          > Having said that you might not want the save code available for every
          > user as a security precaution. If there is only one admin web page that
          > the save goes on then I tend to include the validation and save code on
          > that so I know it's not available to the main website.
          >
          >[/color]

          Thanks. I'm putting the code in there now.


          Comment

          • Jochen Daum

            #6
            Re: OOP page: Where to put update, insert, delete

            Hi jn!
            [color=blue][color=green]
            >> Have a look at the thing in the signature.
            >>
            >> HTH, Jochen
            >>[color=darkred]
            >> >[/color]
            >>
            >> --
            >> Jochen Daum - CANS Ltd.
            >> PHP DB Edit Toolkit -- PHP scripts for building
            >> database editing interfaces.
            >> http://sourceforge.net/projects/phpdbedittk/
            >>[/color]
            >
            >That thing's pretty cool (and complicated) :)
            >[/color]

            Thats right. I haven't been targetting point-and-click users so far,
            rather the guy that has build an admin interface for a database 100
            times.

            Hope it helps still,

            Jochen


            --
            Jochen Daum - CANS Ltd.
            PHP DB Edit Toolkit -- PHP scripts for building
            database editing interfaces.
            Download PHP DB Edit Toolkit for free. PHP DB Edit Toolkit is a set of PHP classes makes the generation of database edit interfaces easier and faster. The main class builds tabular and form views based on a data dictionary and takes over handling of insert/update/delete and user input.

            Comment

            Working...