We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Again, this sounds like a problem in your PHP compile/configuration; there are bugs in many releases/configurations of the PDO drivers, and this sounds like one of them. The connection being reinitialized is a tell-tale sign of these and is likely being accompanied by an Apache segfault.
    • I understand your point, and it is a really weird behaviour.

      Statement written like below work:

      <?php
      $c->select('modResource.*,Author.username AS username');
      ?>
      



      But fail if if try to get less column:

      <?php
      $c->select('modResource.pagetitle AS title, Author.username AS username');
      ?>
      




      I Will dig on google to see if i can found something related.
      • I’ve changed my wamp version for the last one.

        Connection is not reinitialized, but instead i have another error:

        Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 261900 bytes) in D:\TAFF\core\xpdo\om\xpdoobject.class.php on line 71
        
        • Quote from: lossendae at Aug 27, 2009, 06:49 PM

          I’ve changed my wamp version for the last one.

          Connection is not reinitialized, but instead i have another error:

          Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 261900 bytes) in D:\TAFF\core\xpdo\om\xpdoobject.class.php on line 71
          

          Well, that one’s easy, you are pulling more data than is allowed by your memory_limit.
          • That’s what i thought also, but as you can there are 512M allowed which was for testing and also very high.

            Seems like a memory leak or something else to me, no?

            I’ve read several forums where people encounter the same kind of issue with ORM or xmlppc.
            I’ll keep searching since i really need to play with select statement.

            edit:

            It’s really confusing.
            I’ve tested with Wamp -> Apache 2.2.10 - 2.2.11 - 2.2.12 -> PHP 5.2.9 - 5.2.9-1 - 5.2.9-2 - 5.3
            and now with xampp -> Apache 2.2.12 -> PHP 5.3.0

            And it’s always the same result.
            How could the implementation of PDO can be wrong with all those configurations?


            second edit:

            I’m making progress, even if i can’t select specific field from the master class, i can do it on subclasses like that:

            <?php
            //modResource don't accept restrain/custom field for the query
            //modUser which is join in the query can however support any specific field selection even with alias.
            $c->select('modResource.*, CreatedBy.username AS username');
            ?>
            


            It will requier filtering on the output array if necessary.
            • Quote from: lossendae at Aug 27, 2009, 07:35 PM

              That’s what i thought also, but as you can there are 512M allowed which was for testing and also very high.

              Seems like a memory leak or something else to me, no?

              I’ve read several forums where people encounter the same kind of issue with ORM or xmlppc.
              I’ll keep searching since i really need to play with select statement.

              edit:

              It’s really confusing.
              I’ve tested with Wamp -> Apache 2.2.10 - 2.2.11 - 2.2.12 -> PHP 5.2.9 - 5.2.9-1 - 5.2.9-2 - 5.3
              and now with xampp -> Apache 2.2.12 -> PHP 5.3.0

              And it’s always the same result.
              How could the implementation of PDO can be wrong with all those configurations?
              Ok, let’s back up.

              The connection resetting is the only indicator that there is a problem with the PDO driver for MySQL. This can be wrong in all those configurations because the problems are in the MySQL client version that are compiled against PHP, and with all the controversy with MySQL and PDO in the last 2 years, the more recent configurations are the ones that are turning out buggy. BTW, what versions of MySQL server and client are being used in those MAMP/XAMPP versions?

              That said, I now see that you have some problems with what you are attempting to do.

              First, remember that xPDOObjects are a bit heavier in memory usage than just an associative array result set. When working with xPDO, you need to carefully decide if you want to return a collection of objects or just a result set to work with directly. You can manually instantiate objects from that result set as needed using the xPDOObject->fromArray() method, and that works well in some cases. It’s generally never a good idea to select all the rows with all the columns from the modResource (site_content) table; I don’t know how many rows, or how much content you have stored in the content field of those rows, but that could easily come to over 512Mb of data, no matter if you return objects or not.

              Next and regardless of the above, you can achieve what you are trying to do in the second select() call (which is known as lazy loading), BUT YOU MUST INCLUDE ALL PRIMARY KEY COLUMNS, and you cannot rename columns that will be used to load the object, e.g.
              <?php
              $c->select('modResource.id, modResource.pagetitle, Author.username');
              ?>

              That should work fine, and reduce the memory requirements of your objects since they will only include the data for the id and pagetitle fields.

              But, with great power comes great responsibility; beware with lazy loading, because if you try to get() a field that you didn’t include (or all fields with toArray()) on a lazy object, a query will be executed to retrieve each additional column’s data to populate the field values.
              • Thank you for the explanations Jason,

                i didn’t understand that i had to include the id column if i wanted to select specific columns.

                It was confusing, since the tutorial to create schema for xPDO tells us that we don’t have to precise the id column since the builder does it for us.
                I thought that it was the same when querying the database (and did not take attention when i debugged the result in sqlyog)

                Since i can’t use toArray(), i imagine that i have to precise each column in my loop when i want to populate an array from the result or is there another method to do it automatically?

                For Wamp, the MYSQL version is 5.1.36 and for Xampp it’s 5.1.37