right...I realize that it looks like it works, but doesn't really. The object is unserialized but then i get the following errors complaining about the object not being what was expected.

Warning: Couldn't fetch DOMDocument in /home/jamesr/test_apache/htdocs/oat/dom/readNdisplay.php on line 66

Warning: Couldn't fetch DOMDocument in /home/jamesr/test_apache/htdocs/oat/dom/readNdisplay.php on line 68

Fatal error: Call to a member function item() on a non-object in /home/jamesr/test_apache/htdocs/oat/dom/readNdisplay.php on line 69

Thanks, sorry for not being clear.

    when working with OOP and sessions, the class definition must come before the session initialization.

      sorry, i'm still not getting it...

      this is what i've got

      $obj = new DOMDocument();
      $obj->load( 'WeeklySample.xml' );
      session_start();

      if ( !isset($SESSION['ser'])) {
      $serialized = serialize($obj);
      $
      SESSION["ser"] = $serialized;
      }else{
      $obj = unserialize( $_SESSION['ser'] );

      }

      ecksPath( $obj, $start, $end );

      ecksPath expects $obj to be a DOMDocument object.

      Thanks for your patience:bemused:

        
        require_once 'your_class.php';
        
        // THEN 
        session_start():
        
        

          There's no 'my_class.php' i'm making an object that is in the php framework

          www.php.net/dom

          that's the object i need to persist. i appologize. i understand the require_once call when applicable, but it's not in this case...

          sorry 🙁

            Originally posted by wha???
            then sessionizing (i love making up words),

            But why make up UGLY words: sessioning would sound so much nicer. 🆒

            So you want to speed up access to the contents of the file, eh. Try thinking outside the box, or in this case the box-file. XML and Databases

              ok...i do like sessioning

              yeah...i'm using databases to hold absurd amounds of xml files that describe events over time periods...

              i just need to figure out how to persist the object so that i can make the calls to XPath to get the needed data. all the while only getting a chunk @ a time. i just want to do it so that i can see the speed advantages/disadavntages between persisting the object between pages and loading the xml file at every subsequent page.

              Thanks

                i just noticed your serializing your object twice. php automatically serializes all data put into a session. so no need to use serialize() if your putting it into a session.

                try this

                
                session_start();
                
                $obj =& $_SESSION['obj'];
                if (!is_object($obj)) {
                    $obj = new DOMDocument();
                }
                
                
                  session_start();
                  
                  $obj = $_SESSION['obj'];
                  if (!is_object($obj)) {
                      $obj = new DOMDocument();
                      $obj->load( 'WeeklySample.xml' );
                  }
                  
                  ecksPath( $obj, 1, 100 );
                  
                  

                  ecksPath just does some xpath filtering on the xml that it gets and then displays entries accordingly in a table. The errors occur when the obj isn't an object

                  this gave me the same problem, for some reason the object's not being passed over properly. Thanks, i didn't know sessions serialized everything for you. Thanks

                    when you do

                    $var1 = $var2;

                    php by default will pass a COPY of the value to the new variable.

                    when working with objects, this is the same until php5, then objects are passed by reference by default, and other variables are still passed as a copy.

                    same goes for functions. by default they pass a COPY of the value into the function. you can change that though when you define the function.

                    function foo(&$var) {
                        // $var will be passed by reference into the function now
                    }
                    

                    i noticed you removed the =& from the code example i posted, which makes me think your not familiar with references yet.

                    have a read

                    http://www.php.net/references

                      Originally posted by wha???
                      ok...i do like sessioning

                      yeah...i'm using databases to hold absurd amounds of xml files that describe events over time periods...

                      i just need to figure out how to persist the object so that i can make the calls to XPath to get the needed data. all the while only getting a chunk @ a time. i just want to do it so that i can see the speed advantages/disadavntages between persisting the object between pages and loading the xml file at every subsequent page.

                      Thanks

                      And I was hinting that a better idea might be to just use a 'real' database engine if search-and-retrieval is your bottleneck. To my knowledge, making objects persist in Apache/PHP is a non-starter; though I'm sure someone will correct me in this. Seems to be altogether the wrong toolset for the job, hence the performance problems.

                        I wouldn't say there's a performance bottleneck, and as of right now i'm remaking the object on all subsequent page loads, i'd just like to get this working for comparison and for my personal sanity.

                        Also the design's out of my hands, There is XML and it is stored in the db. a user requests a time interval, they then get that interval. however if they request a week's data, there'll be thousands of entries, all of which can't be viewed on the same page. so i'm trying to parse the xml show 100 at a time. it really wouldn't make sense to me to break up a user's query further and save that in the db.

                        Thanks

                          Write a Reply...