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 have code similar to this running inside an xPDOObject:

    $newObject = $this->xpdo->newObject('MyClass'));
    $this->addOne($newObject,'CorrectAlias');
    $saved = $this->save();
    


    The result: Record ’$this’ is saved correctly, but record ’$newObject’ is not added to the DB.

    My workaround:

    $saved = $this->save();
    $newObject = $this->xpdo->newObject('MyClass',array('relatedKey'=>$this->get('id')));
    $newObject->save();
    


    A little strange to have to remember not to use $this->addOne().

    I have, however, successfully used addOne from outside an object:

    $object1->addOne($object2);
    


    MODx 1.0.4, MySQL 5, Apache 2.2, PHP 5.2.12, xPDO-2.0.0-rc1 (Hey I just noticed RC3!)

    To Do: Will try XPDO RC3 and also version that ships with Revo 2.
      • 22303 MODX Staff
      • 10,725 Posts
      I don’t see why it should make a difference. Perhaps a bug in an older version, but let me know.