diff --git a/trunk/pages/run_query.php b/trunk/pages/run_query.php new file mode 100644 index 000000000..c53a4d1fc --- /dev/null +++ b/trunk/pages/run_query.php @@ -0,0 +1,102 @@ +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(); +?> diff --git a/trunk/pages/sibusql.php b/trunk/pages/sibusql.php deleted file mode 100644 index 3780896f2..000000000 --- a/trunk/pages/sibusql.php +++ /dev/null @@ -1,70 +0,0 @@ -FYI: '$sClearText'
\n"; - $oFilter = DBObjectSearch::unserialize($sExpression); - $sExpression = $oFilter->ToOQL(); - exit; - } - else - { - // leave $sExpression as is - } - - $oP->add('
'."\n"); - $oP->add('Expression to evaluate:
'."\n"); - $oP->add(''."

Example:
SELECT bizPerson AS B WHERE B.name LIKE '%A%'

\n"); - $oP->add(''."\n"); - $oP->add('
'."\n"); - - if (!empty($sExpression)) - { - $oFilter = DBObjectSearch::FromOQL($sExpression); - if ($oFilter) - { - $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(); -?> diff --git a/trunk/setup/data/structure/1.menus.xml b/trunk/setup/data/structure/1.menus.xml index 6a262609a..81a61ea63 100644 --- a/trunk/setup/data/structure/1.menus.xml +++ b/trunk/setup/data/structure/1.menus.xml @@ -732,7 +732,7 @@ text-align:center; Run queries -./sibusql.php +./run_query.php administrator