Be careful as this syntax can potentially introduce SQL injections.
PHP's parameterization features in PDO can be abstracted so you can turn this into:
$vars = array(":userid" => $userid);
q("select name from users where id = :userid", $vars);
It's still pretty concise and is much safer.