We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11793
    • 49 Posts
    I just tried using xpdo->getObject() with an "xpdo->newQuery" criteria as the second parameter.

    I’ve noticed that a field that was not explicitly mentioned in the "$criteria->select()" had its default value returned, even after using "->get(’fieldname’)".

    In this case, the database value was not the default value, and it would always return the default.

    Once I added the field name e.g.

    $criteria->select($xpdo->getSelectColumns('ClassName', 'CustomAlias', null, array('id','THE_FIELD_THAT_I_WANT'));


    I was finally able to get the correct value via:

    $MyXpdoObj->get('THE_FIELD_THAT_I_WANT')


    This is the first time I’ve hit this anomaly, since I almost never use $criteria with ->getObject() - I generally use an array.

    Please note that the returned xPDOObject seems fine in every other respect.

    I’m running an older version of XPDO 2.0 on ModX Evo 1.0.4.
      • 22303 MODX Staff
      • 10,725 Posts
      If you don’t return a field, that field is marked as lazy inside the xPDOObject instance, and if you call get() on the field name, another query should be executed to populate the lazy field and the proper value should be returned. Can you provide a simple Snippet or script to reproduce this behavior? Also, have you tried updating to a more recent version of the xPDO code?
        • 11793
        • 49 Posts
        Jason, your description matches my expectation of how it should work - I guess I need to take the plunge and get the latest SVN of xPDO.

        If the problem persists, I’ll post code.

        HB
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: hardboiled at Oct 01, 2010, 06:02 PM

          Jason, your description matches my expectation of how it should work - I guess I need to take the plunge and get the latest SVN of xPDO.
          FWIW, the latest xPDO is now @ GitHub. If you want the entire project, including build and test directories, you’ll want to look at http://github.com/modxcms/xpdo -- or if you just want the runtime framework, you can use http://github.com/modxcms/xpdo-core

          Let me know if you have any questions or continue experiencing the problem.