We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37044
    • 68 Posts
    I have Googled quite a lot but all I seem to get is references to the logon / password functions.

    What I am looking to do is a simple look up / 'select' / 'get' query which is driven out of a hashed link trigger.

    So in native mysql I would do something like:

    SELECT col_name FROM table WHERE MD5(ID) ='***hash_here***'


    But am having real trouble finding how to convert this to XPDO.

    Thanks in advance.
    [ed. note: megasteve4 last edited this post 14 years, 2 months ago.]
      • 37044
      • 68 Posts
      OK seem to have found my own answer pretty much...

      Using xPDOCriteria (see docshttp://rtfm.modx.com/display/xPDO20/Retrieving+Objects)

      Which apparently will parse a string of standard sql into a XPDO format / query.

      $able = $modx->getTableName('OBJECT');
      $query = new xPDOCriteria($modx,'
          SELECT * FROM '.$table.'
          WHERE  md5(row_id) = :rID
      ',array(
        ':rID' => $_POST['rID'],
      ));						
      //DEBUG $query->prepare();
      //DEBUG return $query->toSql();
      $reviews = $modx->getCollection('OBJECT',$query);


      NOTE: I am currently a little unsure if this method will fully escape your input...so I would find out if you are to use this in production (...and post back to be nice!)

      More on escaping here https://forums.modx.com/index.php?topic=67020.0
      [ed. note: megasteve4 last edited this post 14 years, 2 months ago.]