We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17016
    • 138 Posts
    Quote from: BobRay at Aug 12, 2011, 06:38 AM

    The second one should definitely work as long as you place it after the save().
    Hi Bob,
    this is the code which generates correctly a symlink-resource but puts nothing in $idoftxt at the end of the code:
    $fieldstxt = array();
    $fieldtxt['pagetitle'] = $name;
    ...
    $resource = $modx->newObject('modSymlink', $fieldtxt);
    $resource->save();
    
    $idoftxt = mysql_insert_id();
    return $idoftxt;
    

    Do you see anything what I might have done wrong?
    • I imagine the problem is because xPDO uses a PDO connection and not a connection created via mysql_connect() - mysql_insert_id() will always look for a connection created via mysql_connect().

      FYI, the ID is set when you call save(), so you can just use:
      return $resource->get('id');
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 17016
        • 138 Posts
        Quote from: garryn at Aug 12, 2011, 05:34 PM

        FYI, the ID is set when you call save(), so you can just use:
        return $resource->get('id');

        Hi garryn,
        thanks a lot. That works excellent!

        Letti
          • 3749
          • 24,544 Posts
          Doh. I though Letti had already tried that.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 34178
            • 212 Posts
            Quote from: Letti at Aug 09, 2011, 12:33 AM
            ... Perfect! Thanks a lot for your help. As soon as your MODx-Team changed the links on http://modx.com/community/wall-of-fame/ to direct links to the donator (at the moment these are still redirects what is not very good of SEO-reasons grin) we will like to do our next donations smiley)))

            We were going to donate again to the modx-team but unfortunately the links are still redirects. Can anybody of the modx-team tell us if it is intended to change this?