need a pointer on OOP with php

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

    need a pointer on OOP with php

    Hello there,

    i am getting to need to make my web stuff more OO.
    i have a project at work that we are porting to the internet, and i
    started learning php to do so.
    the project is now mamoth is size, and code is reused and pasted all
    over it. I plan to do a good re-write using better, and cleaner code.
    So i want to incorporate some classes.

    So i have some questions.

    i am writing in eclipse and phpedit on linux.
    i wrote a simple class ( by example in a book )

    it goes a little something like this:

    class Customer
    {
    var $name;

    function get_name()
    {
    return $this-name;

    }
    function set_name($new_n ame)
    {
    $this-name = $new_name;
    }
    }

    my parser complains about field declarations not being declared public,
    private, or protected .
    what is this talking about ?

    another question....

    if i create a customer object when say, someone logs into the site. Can
    i pass that object to each page in session variables ? like from the
    login page, can the user move about the site without me coding the
    declarations over and over ?

    or is there a better way to go about this ?
    still a newbie here.

    thanks.

  • Rik

    #2
    Re: need a pointer on OOP with php

    nephish wrote:
    Hello there,
    >
    i am getting to need to make my web stuff more OO.
    i have a project at work that we are porting to the internet, and i
    started learning php to do so.
    the project is now mamoth is size, and code is reused and pasted all
    over it. I plan to do a good re-write using better, and cleaner code.
    So i want to incorporate some classes.
    >
    So i have some questions.
    >
    i am writing in eclipse and phpedit on linux.
    i wrote a simple class ( by example in a book )
    >
    it goes a little something like this:
    >
    class Customer
    {
    var $name;
    >
    function get_name()
    {
    return $this-name;
    >
    }
    function set_name($new_n ame)
    {
    $this-name = $new_name;
    }
    }
    >
    my parser complains about field declarations not being declared
    public, private, or protected .
    what is this talking about ?
    1. If you're serious about OO, learn what they mean.
    2. http://nl3.php.net/manual/en/languag...visibility.php It was
    introduced in PHP in version 5, in 4 it will not work. From the manual:
    "Note: The PHP 4 method of declaring a variable with the var keyword is no
    longer valid for PHP 5 objects. For compatibility a variable declared in php
    will be assumed with public visibility, and a E_STRICT warning will be
    issued."
    another question....
    >
    if i create a customer object when say, someone logs into the site.
    Can i pass that object to each page in session variables ? like from
    the login page, can the user move about the site without me coding the
    declarations over and over ?
    You can:



    You might want to ask yourself wether this is really needed, and why exactly
    some simple variables aren't enough.
    or is there a better way to go about this ?
    Just keep in mind OO isn't neccesarily better, and www.php.net is a great
    source where you would have found answers to this questions very quickly. Be
    sure to read the user contributed notes.

    Grtz,
    --
    Rik Wasmus


    Comment

    • nephish

      #3
      Re: need a pointer on OOP with php

      First off, thanks for the links and the info, especially the first
      link.
      Thats what i needed to know.

      The system at work uses php4, the system i use at home has php5.
      well, suppose i could upgrade works server, but still, passing
      everything around as a stream may be a bit more complicated than i
      wanted to, but still may be worth it.

      i do appreciate the info. Though, i know more about what i am dealing
      with.

      shawn



      Rik wrote:
      nephish wrote:
      Hello there,

      i am getting to need to make my web stuff more OO.
      i have a project at work that we are porting to the internet, and i
      started learning php to do so.
      the project is now mamoth is size, and code is reused and pasted all
      over it. I plan to do a good re-write using better, and cleaner code.
      So i want to incorporate some classes.

      So i have some questions.

      i am writing in eclipse and phpedit on linux.
      i wrote a simple class ( by example in a book )

      it goes a little something like this:

      class Customer
      {
      var $name;

      function get_name()
      {
      return $this-name;

      }
      function set_name($new_n ame)
      {
      $this-name = $new_name;
      }
      }

      my parser complains about field declarations not being declared
      public, private, or protected .
      what is this talking about ?
      >
      1. If you're serious about OO, learn what they mean.
      2. http://nl3.php.net/manual/en/languag...visibility.php It was
      introduced in PHP in version 5, in 4 it will not work. From the manual:
      "Note: The PHP 4 method of declaring a variable with the var keyword is no
      longer valid for PHP 5 objects. For compatibility a variable declared in php
      will be assumed with public visibility, and a E_STRICT warning will be
      issued."
      >
      another question....

      if i create a customer object when say, someone logs into the site.
      Can i pass that object to each page in session variables ? like from
      the login page, can the user move about the site without me coding the
      declarations over and over ?
      >
      You can:


      >
      You might want to ask yourself wether this is really needed, and why exactly
      some simple variables aren't enough.
      >
      or is there a better way to go about this ?
      >
      Just keep in mind OO isn't neccesarily better, and www.php.net is a great
      source where you would have found answers to this questions very quickly. Be
      sure to read the user contributed notes.
      >
      Grtz,
      --
      Rik Wasmus

      Comment

      • Tony Marston

        #4
        Re: need a pointer on OOP with php


        "Rik" <luiheidsgoeroe @hotmail.comwro te in message
        news:b04a6$44d6 3819$8259c69c$7 780@news1.tudel ft.nl...
        nephish wrote:
        >Hello there,
        >>
        >i am getting to need to make my web stuff more OO.
        >i have a project at work that we are porting to the internet, and i
        >started learning php to do so.
        >the project is now mamoth is size, and code is reused and pasted all
        >over it. I plan to do a good re-write using better, and cleaner code.
        >So i want to incorporate some classes.
        >>
        >So i have some questions.
        >>
        >i am writing in eclipse and phpedit on linux.
        >i wrote a simple class ( by example in a book )
        >>
        >it goes a little something like this:
        >>
        >class Customer
        > {
        > var $name;
        >>
        > function get_name()
        > {
        > return $this-name;
        >>
        > }
        > function set_name($new_n ame)
        > {
        > $this-name = $new_name;
        > }
        > }
        >>
        >my parser complains about field declarations not being declared
        >public, private, or protected .
        >what is this talking about ?
        >
        1. If you're serious about OO, learn what they mean.
        2. http://nl3.php.net/manual/en/languag...visibility.php It was
        introduced in PHP in version 5, in 4 it will not work. From the manual:
        "Note: The PHP 4 method of declaring a variable with the var keyword is no
        longer valid for PHP 5 objects. For compatibility a variable declared in
        php
        will be assumed with public visibility, and a E_STRICT warning will be
        issued."
        This behaviour has been recently changed so that the use of the "var"
        keyword does NOT trigger an E_STRICT warning in PHP 5

        I have written software that uses PHP's OO capabilities in PHP 4, and it
        runs perfectly well in PHP 5. Samples of my code are available from the
        websites which appear in my signature.

        --
        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

        Build apps faster with Rapid Application Development using open-source RAD tools, modern RAD frameworks, and rapid application design methods.



        Comment

        • Rik

          #5
          Re: need a pointer on OOP with php

          Tony Marston wrote:
          >>my parser complains about field declarations not being declared
          >>public, private, or protected .
          >>what is this talking about ?
          >>
          >1. If you're serious about OO, learn what they mean.
          >2. http://nl3.php.net/manual/en/languag...visibility.php It was
          >introduced in PHP in version 5, in 4 it will not work. From the
          >manual: "Note: The PHP 4 method of declaring a variable with the var
          >keyword is no longer valid for PHP 5 objects. For compatibility a
          >variable declared in php
          >will be assumed with public visibility, and a E_STRICT warning will
          >be issued."
          >
          This behaviour has been recently changed so that the use of the "var"
          keyword does NOT trigger an E_STRICT warning in PHP 5
          Any idea which version they changed this?
          I have written software that uses PHP's OO capabilities in PHP 4, and
          it runs perfectly well in PHP 5. Samples of my code are available
          from the websites which appear in my signature.
          Yup, my own PHP 5 version works perfectly with my previous PHP 4 code.

          Grtz,
          --
          Rik Wasmus


          Comment

          • Henk Verhoeven

            #6
            Re: need a pointer on OOP with php

            nephish wrote:
            if i create a customer object when say, someone logs into the site. Can
            i pass that object to each page in session variables ? like from the
            login page, can the user move about the site without me coding the
            declarations over and over ?
            >
            or is there a better way to go about this ?
            Hi nephish,

            Theoretically you store objects that should have the same lifetime or
            shorter as the session in the session. Object that have a longer
            lifetime, or have to be shared by multiple users you better store in in
            a database. This is called 'persistency'. For more info on persistency
            see

            Now, next, and beyond: Tracking need-to-know trends at the intersection of business and technology

            The thread "PHP Dynamic Database Code" started by josh.kuo@gmail. com on
            Fri, 9 Jun 2006 23:13:21 +0000 (UTC) (from which i have the above urls)
            may also be interesting.

            Saving objects in the session in practice has often brougt me troubles.
            The point is you must have its class loaded before the session is
            started. This may be easy if you have only one page and one object
            class, but i usually have many of both. In my experience it is more
            reliable to copy all the objects member variables (but not the ones that
            hold objects) into an asspciative array and store the array in the
            session. When you later need the object you copy the values from the
            array back into a new object.

            Furthermore you could take a look at patterns. An example of a pattern
            for user interfacing can be found at:

            Many more patterns are at http://c2.com/cgi-bin/wiki?DesignPatterns
            (if you get lost, try: http://c2.com/cgi-bin/wiki?search=controller )

            Greetings,

            Henk Verhoeven,
            www.phpPeanuts.org.

            Some OO terms and definitions:

            (contains interpretations specific to the phpPeanuts framework)

            Comment

            • nephish

              #7
              Re: need a pointer on OOP with php

              Ok, well what i have been doing is creating session variables for
              everything possible that relates to what one may call an object (not in
              the code, but at the site)
              like $name = $_SESSION['name'];
              $email = $_SESSION['email'];
              $phone = yadda, yadda, yadda

              so, i suppose this is still the easier way to pull this off.
              thanks for all the info, i am trying to learn as much as possible
              because i want to redesign everything in the fall. i started learning
              php about a year ago, and a whole lot of stuff i did last Fall, i would
              do differently this Fall.
              So i want to make it as streamlined as possible.

              thanks for all your help

              shawn



              Henk Verhoeven wrote:
              nephish wrote:
              if i create a customer object when say, someone logs into the site. Can
              i pass that object to each page in session variables ? like from the
              login page, can the user move about the site without me coding the
              declarations over and over ?

              or is there a better way to go about this ?
              >
              Hi nephish,
              >
              Theoretically you store objects that should have the same lifetime or
              shorter as the session in the session. Object that have a longer
              lifetime, or have to be shared by multiple users you better store in in
              a database. This is called 'persistency'. For more info on persistency
              see

              Now, next, and beyond: Tracking need-to-know trends at the intersection of business and technology

              The thread "PHP Dynamic Database Code" started by josh.kuo@gmail. com on
              Fri, 9 Jun 2006 23:13:21 +0000 (UTC) (from which i have the above urls)
              may also be interesting.
              >
              Saving objects in the session in practice has often brougt me troubles.
              The point is you must have its class loaded before the session is
              started. This may be easy if you have only one page and one object
              class, but i usually have many of both. In my experience it is more
              reliable to copy all the objects member variables (but not the ones that
              hold objects) into an asspciative array and store the array in the
              session. When you later need the object you copy the values from the
              array back into a new object.
              >
              Furthermore you could take a look at patterns. An example of a pattern
              for user interfacing can be found at:

              Many more patterns are at http://c2.com/cgi-bin/wiki?DesignPatterns
              (if you get lost, try: http://c2.com/cgi-bin/wiki?search=controller )
              >
              Greetings,
              >
              Henk Verhoeven,
              www.phpPeanuts.org.
              >
              Some OO terms and definitions:

              (contains interpretations specific to the phpPeanuts framework)

              Comment

              • Jerry Stuckle

                #8
                Re: need a pointer on OOP with php

                nephish wrote:
                Ok, well what i have been doing is creating session variables for
                everything possible that relates to what one may call an object (not in
                the code, but at the site)
                like $name = $_SESSION['name'];
                $email = $_SESSION['email'];
                $phone = yadda, yadda, yadda
                >
                so, i suppose this is still the easier way to pull this off.
                thanks for all the info, i am trying to learn as much as possible
                because i want to redesign everything in the fall. i started learning
                php about a year ago, and a whole lot of stuff i did last Fall, i would
                do differently this Fall.
                So i want to make it as streamlined as possible.
                >
                thanks for all your help
                >
                shawn
                >
                >
                How I typically do it (since I have my data in a database) is to store
                the primary key to the entry in my $_SESSION object. Then I fetch
                whatever I need from the database when I need it.

                I find this to be much cleaner code. It also fetches current
                information in the (admittedly unlikely) event the data is changed while
                you're passing it around.

                P.S. Please don't top post. This newsgroup uses bottom (or inline)
                posting as the standard.

                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===

                Comment

                • nephish

                  #9
                  Re: need a pointer on OOP with php


                  Jerry Stuckle wrote:
                  nephish wrote:
                  Ok, well what i have been doing is creating session variables for
                  everything possible that relates to what one may call an object (not in
                  the code, but at the site)
                  like $name = $_SESSION['name'];
                  $email = $_SESSION['email'];
                  $phone = yadda, yadda, yadda

                  so, i suppose this is still the easier way to pull this off.
                  thanks for all the info, i am trying to learn as much as possible
                  because i want to redesign everything in the fall. i started learning
                  php about a year ago, and a whole lot of stuff i did last Fall, i would
                  do differently this Fall.
                  So i want to make it as streamlined as possible.

                  thanks for all your help

                  shawn
                  >
                  How I typically do it (since I have my data in a database) is to store
                  the primary key to the entry in my $_SESSION object. Then I fetch
                  whatever I need from the database when I need it.
                  >
                  I find this to be much cleaner code. It also fetches current
                  information in the (admittedly unlikely) event the data is changed while
                  you're passing it around.
                  >
                  P.S. Please don't top post. This newsgroup uses bottom (or inline)
                  posting as the standard.
                  >
                  --
                  =============== ===
                  Remove the "x" from my email address
                  Jerry Stuckle
                  JDS Computer Training Corp.
                  jstucklex@attgl obal.net
                  =============== ===
                  by bottom post, you mean write my stuff at the bottom of the text entry
                  box ?
                  like this ? Sorry about that. I have kinda wondered which is better.

                  Anyway. I like that idea too. just storing the session variable of the
                  primary key.
                  in my case (user_id_number ), and just using that to conquer everything
                  else.

                  OK, i have another question about this re-write i want to do. Please
                  understand, i started learning php about 10 months ago by building our
                  huge website with it. couple of hundered scripts now.

                  there is a lot i find on the web about MVC. But also found that it
                  seems to be best for simple CRUD. What we have here is a lot more
                  complex. We are pulling machine data, processing it, displaying graphs
                  of machine effeciency, history of machine performance, etc.. Once
                  things get complex like that, not like a blog site or something, does
                  an MVC still make sense ?

                  thanks.

                  sk

                  Comment

                  • Jerry Stuckle

                    #10
                    Re: need a pointer on OOP with php

                    nephish wrote:
                    Jerry Stuckle wrote:
                    >
                    >>nephish wrote:
                    >>
                    >>>Ok, well what i have been doing is creating session variables for
                    >>>everything possible that relates to what one may call an object (not in
                    >>>the code, but at the site)
                    >>>like $name = $_SESSION['name'];
                    >>>$email = $_SESSION['email'];
                    >>>$phone = yadda, yadda, yadda
                    >>>
                    >>>so, i suppose this is still the easier way to pull this off.
                    >>>thanks for all the info, i am trying to learn as much as possible
                    >>>because i want to redesign everything in the fall. i started learning
                    >>>php about a year ago, and a whole lot of stuff i did last Fall, i would
                    >>>do differently this Fall.
                    >>>So i want to make it as streamlined as possible.
                    >>>
                    >>>thanks for all your help
                    >>>
                    >>>shawn
                    >>>
                    >>>
                    >>
                    >>How I typically do it (since I have my data in a database) is to store
                    >>the primary key to the entry in my $_SESSION object. Then I fetch
                    >>whatever I need from the database when I need it.
                    >>
                    >>I find this to be much cleaner code. It also fetches current
                    >>information in the (admittedly unlikely) event the data is changed while
                    >>you're passing it around.
                    >>
                    >>P.S. Please don't top post. This newsgroup uses bottom (or inline)
                    >>posting as the standard.
                    >>
                    >>--
                    >>============= =====
                    >>Remove the "x" from my email address
                    >>Jerry Stuckle
                    >>JDS Computer Training Corp.
                    >>jstucklex@att global.net
                    >>============= =====
                    >
                    >
                    by bottom post, you mean write my stuff at the bottom of the text entry
                    box ?
                    like this ? Sorry about that. I have kinda wondered which is better.
                    >
                    Yep, or intermingled, like this. Thanks.

                    Anyway. I like that idea too. just storing the session variable of the
                    primary key.
                    in my case (user_id_number ), and just using that to conquer everything
                    else.
                    >
                    OK, i have another question about this re-write i want to do. Please
                    understand, i started learning php about 10 months ago by building our
                    huge website with it. couple of hundered scripts now.
                    >
                    there is a lot i find on the web about MVC. But also found that it
                    seems to be best for simple CRUD. What we have here is a lot more
                    complex. We are pulling machine data, processing it, displaying graphs
                    of machine effeciency, history of machine performance, etc.. Once
                    things get complex like that, not like a blog site or something, does
                    an MVC still make sense ?
                    >
                    thanks.
                    >
                    sk
                    >
                    Probably, but I don't use packages. I typically define my own class
                    hierarchy. With a little practice and some templates I created, it
                    doesn't take me long.

                    One set of classes to interface to the database, then one on top of that
                    for the business logic.


                    --
                    =============== ===
                    Remove the "x" from my email address
                    Jerry Stuckle
                    JDS Computer Training Corp.
                    jstucklex@attgl obal.net
                    =============== ===

                    Comment

                    • nephish

                      #11
                      Re: need a pointer on OOP with php


                      Jerry Stuckle wrote:
                      nephish wrote:
                      Jerry Stuckle wrote:
                      >nephish wrote:
                      >
                      >>Ok, well what i have been doing is creating session variables for
                      >>everything possible that relates to what one may call an object (not in
                      >>the code, but at the site)
                      >>like $name = $_SESSION['name'];
                      >>$email = $_SESSION['email'];
                      >>$phone = yadda, yadda, yadda
                      >>
                      >>so, i suppose this is still the easier way to pull this off.
                      >>thanks for all the info, i am trying to learn as much as possible
                      >>because i want to redesign everything in the fall. i started learning
                      >>php about a year ago, and a whole lot of stuff i did last Fall, i would
                      >>do differently this Fall.
                      >>So i want to make it as streamlined as possible.
                      >>
                      >>thanks for all your help
                      >>
                      >>shawn
                      >>
                      >>
                      >
                      >How I typically do it (since I have my data in a database) is to store
                      >the primary key to the entry in my $_SESSION object. Then I fetch
                      >whatever I need from the database when I need it.
                      >
                      >I find this to be much cleaner code. It also fetches current
                      >information in the (admittedly unlikely) event the data is changed while
                      >you're passing it around.
                      >
                      >P.S. Please don't top post. This newsgroup uses bottom (or inline)
                      >posting as the standard.
                      >
                      >--
                      >============== ====
                      >Remove the "x" from my email address
                      >Jerry Stuckle
                      >JDS Computer Training Corp.
                      >jstucklex@attg lobal.net
                      >============== ====

                      by bottom post, you mean write my stuff at the bottom of the text entry
                      box ?
                      like this ? Sorry about that. I have kinda wondered which is better.
                      >
                      Yep, or intermingled, like this. Thanks.
                      >
                      >
                      Anyway. I like that idea too. just storing the session variable of the
                      primary key.
                      in my case (user_id_number ), and just using that to conquer everything
                      else.

                      OK, i have another question about this re-write i want to do. Please
                      understand, i started learning php about 10 months ago by building our
                      huge website with it. couple of hundered scripts now.

                      there is a lot i find on the web about MVC. But also found that it
                      seems to be best for simple CRUD. What we have here is a lot more
                      complex. We are pulling machine data, processing it, displaying graphs
                      of machine effeciency, history of machine performance, etc.. Once
                      things get complex like that, not like a blog site or something, does
                      an MVC still make sense ?

                      thanks.

                      sk
                      >
                      Probably, but I don't use packages. I typically define my own class
                      hierarchy. With a little practice and some templates I created, it
                      doesn't take me long.
                      >
                      One set of classes to interface to the database, then one on top of that
                      for the business logic.
                      >
                      >
                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      jstucklex@attgl obal.net
                      =============== ===
                      now, i had thought of that, because what we are doing is as far from
                      Drupal as one can imagine. I just thought it might be easier to try to
                      customize something else. I kinda don't get along with PEAR for db
                      stuff, but i like it for mail. i suppose i can write my own templates.
                      At least i would know how it works.

                      thanks

                      Comment

                      • Jerry Stuckle

                        #12
                        Re: need a pointer on OOP with php

                        nephish wrote:
                        Jerry Stuckle wrote:
                        >
                        >>nephish wrote:
                        >>
                        >>>Jerry Stuckle wrote:
                        >>>
                        >>>
                        >>>>nephish wrote:
                        >>>>
                        >>>>
                        >>>>>Ok, well what i have been doing is creating session variables for
                        >>>>>everythi ng possible that relates to what one may call an object (not in
                        >>>>>the code, but at the site)
                        >>>>>like $name = $_SESSION['name'];
                        >>>>>$email = $_SESSION['email'];
                        >>>>>$phone = yadda, yadda, yadda
                        >>>>>
                        >>>>>so, i suppose this is still the easier way to pull this off.
                        >>>>>thanks for all the info, i am trying to learn as much as possible
                        >>>>>because i want to redesign everything in the fall. i started learning
                        >>>>>php about a year ago, and a whole lot of stuff i did last Fall, i would
                        >>>>>do differently this Fall.
                        >>>>>So i want to make it as streamlined as possible.
                        >>>>>
                        >>>>>thanks for all your help
                        >>>>>
                        >>>>>shawn
                        >>>>>
                        >>>>>
                        >>>>
                        >>>>How I typically do it (since I have my data in a database) is to store
                        >>>>the primary key to the entry in my $_SESSION object. Then I fetch
                        >>>>whatever I need from the database when I need it.
                        >>>>
                        >>>>I find this to be much cleaner code. It also fetches current
                        >>>>informati on in the (admittedly unlikely) event the data is changed while
                        >>>>you're passing it around.
                        >>>>
                        >>>>P.S. Please don't top post. This newsgroup uses bottom (or inline)
                        >>>>posting as the standard.
                        >>>>
                        >>>>--
                        >>>>=========== =======
                        >>>>Remove the "x" from my email address
                        >>>>Jerry Stuckle
                        >>>>JDS Computer Training Corp.
                        >>>>jstucklex@a ttglobal.net
                        >>>>=========== =======
                        >>>
                        >>>
                        >>>by bottom post, you mean write my stuff at the bottom of the text entry
                        >>>box ?
                        >>>like this ? Sorry about that. I have kinda wondered which is better.
                        >>>
                        >>
                        >>Yep, or intermingled, like this. Thanks.
                        >>
                        >>
                        >>
                        >>>Anyway. I like that idea too. just storing the session variable of the
                        >>>primary key.
                        >>>in my case (user_id_number ), and just using that to conquer everything
                        >>>else.
                        >>>
                        >>>OK, i have another question about this re-write i want to do. Please
                        >>>understand , i started learning php about 10 months ago by building our
                        >>>huge website with it. couple of hundered scripts now.
                        >>>
                        >>>there is a lot i find on the web about MVC. But also found that it
                        >>>seems to be best for simple CRUD. What we have here is a lot more
                        >>>complex. We are pulling machine data, processing it, displaying graphs
                        >>>of machine effeciency, history of machine performance, etc.. Once
                        >>>things get complex like that, not like a blog site or something, does
                        >>>an MVC still make sense ?
                        >>>
                        >>>thanks.
                        >>>
                        >>>sk
                        >>>
                        >>
                        >>Probably, but I don't use packages. I typically define my own class
                        >>hierarchy. With a little practice and some templates I created, it
                        >>doesn't take me long.
                        >>
                        >>One set of classes to interface to the database, then one on top of that
                        >>for the business logic.
                        >>
                        >>
                        >>--
                        >>============= =====
                        >>Remove the "x" from my email address
                        >>Jerry Stuckle
                        >>JDS Computer Training Corp.
                        >>jstucklex@att global.net
                        >>============= =====
                        >
                        >
                        now, i had thought of that, because what we are doing is as far from
                        Drupal as one can imagine. I just thought it might be easier to try to
                        customize something else. I kinda don't get along with PEAR for db
                        stuff, but i like it for mail. i suppose i can write my own templates.
                        At least i would know how it works.
                        >
                        thanks
                        >
                        I don't use PEAR, either. Just the mysqli classes on PHP 5 (before I
                        used the mysql interface).

                        I have a generic database class template and a table template I can
                        easily modify. One of these days I'll write a little code to fetch the
                        columns in the table and gen the entire class. But I never bothered
                        because it only takes a few minutes to gen the entire class by hand.
                        Then I modify it for table-specific stuff and I'm done.

                        The whole thing goes pretty quickly.


                        --
                        =============== ===
                        Remove the "x" from my email address
                        Jerry Stuckle
                        JDS Computer Training Corp.
                        jstucklex@attgl obal.net
                        =============== ===

                        Comment

                        • nephish

                          #13
                          Re: need a pointer on OOP with php


                          Jerry Stuckle wrote:
                          nephish wrote:
                          Jerry Stuckle wrote:
                          >nephish wrote:
                          >
                          >>Jerry Stuckle wrote:
                          >>
                          >>
                          >>>nephish wrote:
                          >>>
                          >>>
                          >>>>Ok, well what i have been doing is creating session variables for
                          >>>>everythin g possible that relates to what one may call an object (not in
                          >>>>the code, but at the site)
                          >>>>like $name = $_SESSION['name'];
                          >>>>$email = $_SESSION['email'];
                          >>>>$phone = yadda, yadda, yadda
                          >>>>
                          >>>>so, i suppose this is still the easier way to pull this off.
                          >>>>thanks for all the info, i am trying to learn as much as possible
                          >>>>because i want to redesign everything in the fall. i started learning
                          >>>>php about a year ago, and a whole lot of stuff i did last Fall, i would
                          >>>>do differently this Fall.
                          >>>>So i want to make it as streamlined as possible.
                          >>>>
                          >>>>thanks for all your help
                          >>>>
                          >>>>shawn
                          >>>>
                          >>>>
                          >>>
                          >>>How I typically do it (since I have my data in a database) is to store
                          >>>the primary key to the entry in my $_SESSION object. Then I fetch
                          >>>whatever I need from the database when I need it.
                          >>>
                          >>>I find this to be much cleaner code. It also fetches current
                          >>>informatio n in the (admittedly unlikely) event the data is changed while
                          >>>you're passing it around.
                          >>>
                          >>>P.S. Please don't top post. This newsgroup uses bottom (or inline)
                          >>>posting as the standard.
                          >>>
                          >>>--
                          >>>============ ======
                          >>>Remove the "x" from my email address
                          >>>Jerry Stuckle
                          >>>JDS Computer Training Corp.
                          >>>jstucklex@at tglobal.net
                          >>>============ ======
                          >>
                          >>
                          >>by bottom post, you mean write my stuff at the bottom of the text entry
                          >>box ?
                          >>like this ? Sorry about that. I have kinda wondered which is better.
                          >>
                          >
                          >Yep, or intermingled, like this. Thanks.
                          >
                          >
                          >
                          >>Anyway. I like that idea too. just storing the session variable of the
                          >>primary key.
                          >>in my case (user_id_number ), and just using that to conquer everything
                          >>else.
                          >>
                          >>OK, i have another question about this re-write i want to do. Please
                          >>understand, i started learning php about 10 months ago by building our
                          >>huge website with it. couple of hundered scripts now.
                          >>
                          >>there is a lot i find on the web about MVC. But also found that it
                          >>seems to be best for simple CRUD. What we have here is a lot more
                          >>complex. We are pulling machine data, processing it, displaying graphs
                          >>of machine effeciency, history of machine performance, etc.. Once
                          >>things get complex like that, not like a blog site or something, does
                          >>an MVC still make sense ?
                          >>
                          >>thanks.
                          >>
                          >>sk
                          >>
                          >
                          >Probably, but I don't use packages. I typically define my own class
                          >hierarchy. With a little practice and some templates I created, it
                          >doesn't take me long.
                          >
                          >One set of classes to interface to the database, then one on top of that
                          >for the business logic.
                          >
                          >
                          >--
                          >============== ====
                          >Remove the "x" from my email address
                          >Jerry Stuckle
                          >JDS Computer Training Corp.
                          >jstucklex@attg lobal.net
                          >============== ====

                          now, i had thought of that, because what we are doing is as far from
                          Drupal as one can imagine. I just thought it might be easier to try to
                          customize something else. I kinda don't get along with PEAR for db
                          stuff, but i like it for mail. i suppose i can write my own templates.
                          At least i would know how it works.

                          thanks
                          >
                          I don't use PEAR, either. Just the mysqli classes on PHP 5 (before I
                          used the mysql interface).
                          >
                          I have a generic database class template and a table template I can
                          easily modify. One of these days I'll write a little code to fetch the
                          columns in the table and gen the entire class. But I never bothered
                          because it only takes a few minutes to gen the entire class by hand.
                          Then I modify it for table-specific stuff and I'm done.
                          >
                          The whole thing goes pretty quickly.
                          >
                          >
                          --
                          =============== ===
                          Remove the "x" from my email address
                          Jerry Stuckle
                          JDS Computer Training Corp.
                          jstucklex@attgl obal.net
                          =============== ===
                          Thats what i had in mind, i need desperately to clean up how all my
                          stuff works now,
                          but i could make a class that defines a customer, or a customers
                          machine, and populate it on the fly from an sql look-up, and keep it
                          constant throuout. Thats my main mess now, as i learned new stuff, the
                          site is less and less consistant.

                          Thanks for your help and advise.

                          shawn

                          Comment

                          Working...