Skip to content

Instantly share code, notes, and snippets.

@SugarCRMExamples
Last active August 29, 2015 13:57
Show Gist options
  • Save SugarCRMExamples/9409735 to your computer and use it in GitHub Desktop.
Save SugarCRMExamples/9409735 to your computer and use it in GitHub Desktop.
<?php
function getAtRisk($api, $args)
{
$seed = BeanFactory::newBean('Accounts');
$q = new SugarQuery();
// Set from to the bean first so SugarQuery can figure out joins and fields on the first try
$q->from($seed);
// Adding the ID field so we can validate the results from the select
$q->select('id');
$q->limit(5);
// Return the raw SQL results through the API
return $q->execute();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment