PHP code/libraries for creating MySQL databases

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

    #1

    PHP code/libraries for creating MySQL databases

    Hi All,

    I am working on a registration system, and one of the things I am going to
    need to be able to do it setup the database tables for each event that I
    have registration for. Normally I would do this by hand, but I am wondering
    if there are any code libraries out there that could generate the SQL for
    me.

    Basically I would have a list of column names and types. I know I could
    just foreach() through the list, with a switch to divert control to the
    different code segments depending on the column type, and at the end I would
    have the SQL generated.

    This seems like the sort of thing that somebody might have done before and
    released a code snippet for. Maybe in PEAR DB? Any ideas?

    Sincerely,
    -Josh


  • Tony Marston

    #2
    Re: PHP code/libraries for creating MySQL databases

    Why on earth don't you use phpMyAdmin? Everybody else does. Visit
    http://www.phpmyadmin.net and download the source.

    --
    Tony Marston

    This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL





    "Joshua Beall" <jbeall@donotsp am.remove.me.he raldic.us> wrote in message
    news:p2bId.1081 2$ef6.10589@trn ddc07...[color=blue]
    > Hi All,
    >
    > I am working on a registration system, and one of the things I am going to
    > need to be able to do it setup the database tables for each event that I
    > have registration for. Normally I would do this by hand, but I am
    > wondering if there are any code libraries out there that could generate
    > the SQL for me.
    >
    > Basically I would have a list of column names and types. I know I could
    > just foreach() through the list, with a switch to divert control to the
    > different code segments depending on the column type, and at the end I
    > would have the SQL generated.
    >
    > This seems like the sort of thing that somebody might have done before and
    > released a code snippet for. Maybe in PEAR DB? Any ideas?
    >
    > Sincerely,
    > -Josh
    >[/color]


    Comment

    • Joshua Beall

      #3
      Re: PHP code/libraries for creating MySQL databases

      "Tony Marston" <tony@NOSPAM.de mon.co.uk> wrote in message
      news:csrfv2$6ua $1$830fa17d@new s.demon.co.uk.. .[color=blue]
      > Why on earth don't you use phpMyAdmin? Everybody else does. Visit
      > http://www.phpmyadmin.net and download the source.[/color]

      I must not have asked my question clearly enough - I do not need an end user
      application. I was looking for a code library

      Scraping the bits I want out of phpMyAdmin is of course an option. But I
      was wondering if there was an existing libraries out there that I could just
      drop in to place (or include() in place, as the case may be).


      Comment

      • Geoff Berrow

        #4
        Re: PHP code/libraries for creating MySQL databases

        I noticed that Message-ID: <p2bId.10812$ef 6.10589@trnddc0 7> from Joshua
        Beall contained the following:
        [color=blue]
        >I am working on a registration system, and one of the things I am going to
        >need to be able to do it setup the database tables for each event that I
        >have registration for. Normally I would do this by hand, but I am wondering
        >if there are any code libraries out there that could generate the SQL for
        >me.[/color]

        A table for each event? Are you sure you mean that?
        --
        Geoff Berrow (put thecat out to email)
        It's only Usenet, no one dies.
        My opinions, not the committee's, mine.
        Simple RFDs http://www.ckdog.co.uk/rfdmaker/

        Comment

        • Joshua Beall

          #5
          Re: PHP code/libraries for creating MySQL databases

          "Geoff Berrow" <bl@ckdog.co.uk > wrote in message
          news:qoh2v0tvr0 a1vn9g32pqi6i3n opc3jvhub@4ax.c om...[color=blue]
          >I noticed that Message-ID: <p2bId.10812$ef 6.10589@trnddc0 7> from Joshua
          > Beall contained the following:
          >[color=green]
          >>I am working on a registration system, and one of the things I am going to
          >>need to be able to do it setup the database tables for each event that I
          >>have registration for. Normally I would do this by hand, but I am
          >>wondering
          >>if there are any code libraries out there that could generate the SQL for
          >>me.[/color]
          >
          > A table for each event? Are you sure you mean that?[/color]

          Do you have another suggestion? I couldn't think of any other way to do it,
          since the information collected for each event will be different (possibly
          *very* different).

          I'm open to new ideas, though.


          Comment

          • Geoff Berrow

            #6
            Re: PHP code/libraries for creating MySQL databases

            I noticed that Message-ID: <MJbId.3567$BL3 .3361@trnddc01> from Joshua
            Beall contained the following:
            [color=blue][color=green]
            >> A table for each event? Are you sure you mean that?[/color]
            >
            >Do you have another suggestion? I couldn't think of any other way to do it,
            >since the information collected for each event will be different (possibly
            >*very* different).[/color]

            Ah I see what you mean. So an event is like a conference and you want
            to store delegate details. Some events may just want name and address
            some may want name address, flight details, nationality and so on?

            I still don't see why you can't use phpMyadmin to create the tables...
            --
            Geoff Berrow (put thecat out to email)
            It's only Usenet, no one dies.
            My opinions, not the committee's, mine.
            Simple RFDs http://www.ckdog.co.uk/rfdmaker/

            Comment

            • ncf

              #7
              Re: PHP code/libraries for creating MySQL databases

              Why not use one table to hold all the events, and another to hold the
              details or whatever you need to hold and the ID of the event. Then you
              can access it with a query such as

              SELECT * FROM events AS e JOIN details AS d ON (e.id=d.event_i d)
              Best of Luck.

              -Wes

              Comment

              • Joshua Beall

                #8
                Re: PHP code/libraries for creating MySQL databases

                "Geoff Berrow" <bl@ckdog.co.uk > wrote in message
                news:ohl2v01en4 uj0nqcuusobanmg cef8lu3l7@4ax.c om...[color=blue][color=green]
                >>Do you have another suggestion? I couldn't think of any other way to do
                >>it,
                >>since the information collected for each event will be different (possibly
                >>*very* different).[/color]
                >
                > Ah I see what you mean. So an event is like a conference and you want
                > to store delegate details. Some events may just want name and address
                > some may want name address, flight details, nationality and so on?[/color]

                Right, exactly.
                [color=blue]
                > I still don't see why you can't use phpMyadmin to create the tables...[/color]

                Well, I *could*, I'm just wondering if there is a way I could automate the
                process. See, my end goal is to just be able to write up an XML file that
                describes the conference (name, fields, what fields are required, etc), and
                then be able to run a script that will generate the form to collect the
                information and the table where that info will be stored.

                But I think where I'm landing for now is to just do make the table by hand.
                Some time down the road I may try and make it more automated.


                Comment

                • Joshua Beall

                  #9
                  Re: PHP code/libraries for creating MySQL databases

                  "ncf" <nothingcanfulf ill@gmail.com> wrote in message
                  news:1106336931 .467726.132010@ c13g2000cwb.goo glegroups.com.. .[color=blue]
                  > Why not use one table to hold all the events, and another to hold the
                  > details or whatever you need to hold and the ID of the event. Then you
                  > can access it with a query such as
                  >
                  > SELECT * FROM events AS e JOIN details AS d ON (e.id=d.event_i d)[/color]

                  The thing is that this would produce multiple rows for one entry in the
                  events table. I'd rather not do that. :-/


                  Comment

                  • Jerry Gitomer

                    #10
                    Re: PHP code/libraries for creating MySQL databases

                    Joshua Beall wrote:[color=blue]
                    > "Geoff Berrow" <bl@ckdog.co.uk > wrote in message
                    > news:ohl2v01en4 uj0nqcuusobanmg cef8lu3l7@4ax.c om...
                    >[color=green][color=darkred]
                    >>>Do you have another suggestion? I couldn't think of any other way to do
                    >>>it,
                    >>>since the information collected for each event will be different (possibly
                    >>>*very* different).[/color]
                    >>
                    >>Ah I see what you mean. So an event is like a conference and you want
                    >>to store delegate details. Some events may just want name and address
                    >>some may want name address, flight details, nationality and so on?[/color]
                    >
                    >
                    > Right, exactly.
                    >
                    >[color=green]
                    >>I still don't see why you can't use phpMyadmin to create the tables...[/color]
                    >
                    >
                    > Well, I *could*, I'm just wondering if there is a way I could automate the
                    > process. See, my end goal is to just be able to write up an XML file that
                    > describes the conference (name, fields, what fields are required, etc), and
                    > then be able to run a script that will generate the form to collect the
                    > information and the table where that info will be stored.
                    >
                    > But I think where I'm landing for now is to just do make the table by hand.
                    > Some time down the road I may try and make it more automated.
                    >
                    >[/color]
                    I have found that cut and paste is my friend. For me it is
                    faster and easier to create model procedures and then modify
                    them to suit individual applications/tables. Use your favorite
                    editor to build three php programs, one to create a table with a
                    primary key and one to generate a form to collect the data to be
                    used in populating the table and one to process and store the
                    data.

                    To handle a new event copy the three progams, edit, execute,
                    test and verify the results. You should be able to add a new
                    event in less than ten minutes.

                    HTH
                    Jerry

                    Comment

                    • Tony Marston

                      #11
                      Re: PHP code/libraries for creating MySQL databases

                      It now appears that the problem your were asking this newsgroup to solve was
                      totally unrelated to the subject line.

                      "PHP code/libraries for creating MySQL databases" is about CREATING
                      databases, not maintaining the contents of databases.

                      If you do not ask the right question then how are we supposed to supply the
                      right answer?

                      If you want to look at the method I have created for automating this process
                      then take a look at the following articles:






                      The last article contains a link where you can run my sample application
                      online, with another to download the source code to see how it's done.

                      Hope this helps.

                      --
                      Tony Marston

                      This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL




                      "Jerry Gitomer" <jgitomer@veriz on.net> wrote in message
                      news:sTkId.7849 $hC2.6999@trndn y04...[color=blue]
                      > Joshua Beall wrote:[color=green]
                      >> "Geoff Berrow" <bl@ckdog.co.uk > wrote in message
                      >> news:ohl2v01en4 uj0nqcuusobanmg cef8lu3l7@4ax.c om...
                      >>[color=darkred]
                      >>>>Do you have another suggestion? I couldn't think of any other way to do
                      >>>>it,
                      >>>>since the information collected for each event will be different
                      >>>>(possibly
                      >>>>*very* different).
                      >>>
                      >>>Ah I see what you mean. So an event is like a conference and you want
                      >>>to store delegate details. Some events may just want name and address
                      >>>some may want name address, flight details, nationality and so on?[/color]
                      >>
                      >>
                      >> Right, exactly.
                      >>
                      >>[color=darkred]
                      >>>I still don't see why you can't use phpMyadmin to create the tables...[/color]
                      >>
                      >>
                      >> Well, I *could*, I'm just wondering if there is a way I could automate
                      >> the process. See, my end goal is to just be able to write up an XML file
                      >> that describes the conference (name, fields, what fields are required,
                      >> etc), and then be able to run a script that will generate the form to
                      >> collect the information and the table where that info will be stored.
                      >>
                      >> But I think where I'm landing for now is to just do make the table by
                      >> hand. Some time down the road I may try and make it more automated.[/color]
                      > I have found that cut and paste is my friend. For me it is faster and
                      > easier to create model procedures and then modify them to suit individual
                      > applications/tables. Use your favorite editor to build three php
                      > programs, one to create a table with a primary key and one to generate a
                      > form to collect the data to be used in populating the table and one to
                      > process and store the data.
                      >
                      > To handle a new event copy the three progams, edit, execute, test and
                      > verify the results. You should be able to add a new event in less than
                      > ten minutes.
                      >
                      > HTH
                      > Jerry[/color]


                      Comment

                      • Michael Vilain

                        #12
                        Re: PHP code/libraries for creating MySQL databases

                        In article <8AbId.3566$BL3 .127@trnddc01>,
                        "Joshua Beall" <jbeall@donotsp am.remove.me.he raldic.us> wrote:
                        [color=blue]
                        > "Tony Marston" <tony@NOSPAM.de mon.co.uk> wrote in message
                        > news:csrfv2$6ua $1$830fa17d@new s.demon.co.uk.. .[color=green]
                        > > Why on earth don't you use phpMyAdmin? Everybody else does. Visit
                        > > http://www.phpmyadmin.net and download the source.[/color]
                        >
                        > I must not have asked my question clearly enough - I do not need an end user
                        > application. I was looking for a code library
                        >
                        > Scraping the bits I want out of phpMyAdmin is of course an option. But I
                        > was wondering if there was an existing libraries out there that I could just
                        > drop in to place (or include() in place, as the case may be).[/color]

                        Yeah, after reading this thread, I'm still confused about what you're
                        trying to do and what your requirements are. A class with functions to
                        manipulate MySQL databases? Something to populate an existing database?

                        For a class, there are a number of things out there. There's PEAR's DB.
                        I use an SQL class I got from http://www.phpclasses.org

                        Try explaining more fully what your trying to accomplish rather than a
                        solution.

                        --
                        DeeDee, don't press that button! DeeDee! NO! Dee...



                        Comment

                        Working...