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.
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
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]]`
]]
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.