You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under the Select a Single Record the code example $result = $modx->query("SELECT * FROM modx_users WHERE id=1"); if (!is_object($result)) { return 'No result!'; } else { $row = $result->fetch(PDO::FETCH_ASSOC); return 'Result:' .print_r($row,true); }
Will always return true so should be something like $result = $modx->query("SELECT * FROM modx_users WHERE id=1"); if(!$result->fetch(PDO::FETCH_ASSOC)) { return 'No result!'; } else { $row = $result->fetch(PDO::FETCH_ASSOC); return 'Result:' .print_r($row,true); }
The text was updated successfully, but these errors were encountered:
Affected page(s)
https://docs.modx.com/3.x/en/extending-modx/xpdo/class-reference/xpdo/xpdo.query
What needs to be improved?
Under the Select a Single Record the code example
$result = $modx->query("SELECT * FROM modx_users WHERE id=1"); if (!is_object($result)) { return 'No result!'; } else { $row = $result->fetch(PDO::FETCH_ASSOC); return 'Result:' .print_r($row,true); }
Will always return true so should be something like
$result = $modx->query("SELECT * FROM modx_users WHERE id=1"); if(!$result->fetch(PDO::FETCH_ASSOC)) { return 'No result!'; } else { $row = $result->fetch(PDO::FETCH_ASSOC); return 'Result:' .print_r($row,true); }
The text was updated successfully, but these errors were encountered: