FYI: '$sClearText'
\n"; $oFilter = DBObjectSearch::unserialize($sExpression); $sExpression = $oFilter->ToOQL(); exit; } else { // leave $sExpression as is } $aExamples = array( "Applications" => "SELECT bizApplication", "Changes planned on new year's day" => "SELECT bizChangeTicket AS ch WHERE ch.start_date >= '2009-12-31' AND ch.end_date <= '2010-01-01'", "Person having an 'A' in their name" => "SELECT bizPerson AS B WHERE B.name LIKE '%A%'", "NW interfaces of equipment in production for customer 'Demo'" => "SELECT bizInterface AS if JOIN bizDevice AS dev ON if.device_id = dev.id WHERE if.status = 'production' AND dev.status = 'production' AND dev.org_name = 'Demo' AND if.physical_type = 'ethernet'" ); $oP->add("
\n"); $oP->add("Expression to evaluate:
\n"); $oP->add("\n"); $oP->add("\n"); $oP->add("
\n"); $oP->add("

Examples

\n"); $aDisplayData = array(); foreach($aExamples as $sDescription => $sOql) { $sHighlight = ''; $sDisable = ''; if ($sOql == $sExpression) { // this one is currently being tested, highlight it $sHighlight = "background-color:yellow;"; $sDisable = 'disabled'; } $aDisplayData[] = array( 'desc' => "
$sDescription
", 'oql' => "
$sOql
", 'go' => "
\n", ); } $aDisplayConfig = array(); $aDisplayConfig['desc'] = array('label' => 'Target', 'description' => ''); $aDisplayConfig['oql'] = array('label' => 'OQL Expression', 'description' => ''); $aDisplayConfig['go'] = array('label' => '', 'description' => ''); $oP->table($aDisplayConfig, $aDisplayData); if (!empty($sExpression)) { $oFilter = DBObjectSearch::FromOQL($sExpression); if ($oFilter) { $oP->add("

Query results

\n"); $oP->p('Query expression: '.$oFilter->ToOQL()); $oP->p('Serialized filter: '.$oFilter->serialize()); $oSet = new CMDBObjectSet($oFilter); $oP->p('The query returned '.$oSet->count().' results(s)'); cmdbAbstractObject::DisplaySet($oP, $oSet); } } } catch(CoreException $e) { $oP->p('An error occured while running the query:'); $oP->p($e->getHtmlDesc()); } catch(Exception $e) { $oP->p('An error occured while running the query:'); $oP->p($e->getMessage()); } $oP->output(); ?>