We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37523
    • 141 Posts
    Hi All,

    I am very new to the whole mysql query thing and trying to convert the following SQL query into xPDO. I wish the result to be returned as a String but I only seem to get an Object

    SELECT `description` FROM `modx_membergroup_names` WHERE `name` = 'kjsp'


    I have attempted to start with:
    $fundName = $modx->query("SELECT `description` FROM `modx_membergroup_names` WHERE `name` = 'kjsp'");
    $modx->setPlaceHolder('fundName',$fundName);


    which returns "Object" of type PDOStatement.

    How do I get xPDO to execute the PDOStatement and output a string?

    Any suggestion will be greatly appreciated.

    Many thanks in advance.

    This question has been answered by Bruno17. See the first response.

      Glyn Szasz
      Sydney, Australia

      Happy to help (when can) and happy to learn

      If you are a Sydney based MODX developer would love to hear from you. Please contact me.
    • discuss.answer
      • 4172
      • 5,888 Posts
      in this case you can get the modUserGroup - object this way:

      if ($object = $modx->getObject('modUserGroup',array('name'=>'kjsp'))){
          $fundName = $object->get('description');
          $modx->setPlaceholder('fundName',$fundName);    
      }


      or for example with migxLoopCollection

      [[migxLoopCollection? 
      &classname=`modUserGroup`
      &where=`{"name":"kjsp"}`
      &tpl=`@CODE:[[+description]]`
      ]]


        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 37523
        • 141 Posts
        Many thanks Bruno the above worked.
          Glyn Szasz
          Sydney, Australia

          Happy to help (when can) and happy to learn

          If you are a Sydney based MODX developer would love to hear from you. Please contact me.