本文整理汇总了PHP中DBObjectSearch::MakeSelectQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP DBObjectSearch::MakeSelectQuery方法的具体用法?PHP DBObjectSearch::MakeSelectQuery怎么用?PHP DBObjectSearch::MakeSelectQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObjectSearch
的用法示例。
在下文中一共展示了DBObjectSearch::MakeSelectQuery方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MakeSingleRow
public static function MakeSingleRow($sClass, $iKey, $bMustBeFound = true, $bAllowAllData = false, $aModifierProperties = null)
{
// Build the query cache signature
//
$sQuerySign = $sClass;
if ($bAllowAllData) {
$sQuerySign .= '_all_';
}
if (count($aModifierProperties)) {
array_multisort($aModifierProperties);
$sModifierProperties = json_encode($aModifierProperties);
$sQuerySign .= '_all_' . md5($sModifierProperties);
}
if (!array_key_exists($sQuerySign, self::$aQueryCacheGetObject)) {
// NOTE: Quick and VERY dirty caching mechanism which relies on
// the fact that the string '987654321' will never appear in the
// standard query
// This could be simplified a little, relying solely on the query cache,
// but this would slow down -by how much time?- the application
$oFilter = new DBObjectSearch($sClass);
$oFilter->AddCondition('id', 987654321, '=');
if ($aModifierProperties) {
foreach ($aModifierProperties as $sPluginClass => $aProperties) {
foreach ($aProperties as $sProperty => $value) {
$oFilter->SetModifierProperty($sPluginClass, $sProperty, $value);
}
}
}
if ($bAllowAllData) {
$oFilter->AllowAllData();
}
$sSQL = $oFilter->MakeSelectQuery();
self::$aQueryCacheGetObject[$sQuerySign] = $sSQL;
self::$aQueryCacheGetObjectHits[$sQuerySign] = 0;
} else {
$sSQL = self::$aQueryCacheGetObject[$sQuerySign];
self::$aQueryCacheGetObjectHits[$sQuerySign] += 1;
// echo " -load $sClass/$iKey- ".self::$aQueryCacheGetObjectHits[$sQuerySign]."<br/>\n";
}
$sSQL = str_replace(CMDBSource::Quote(987654321), CMDBSource::Quote($iKey), $sSQL);
$res = CMDBSource::Query($sSQL);
$aRow = CMDBSource::FetchArray($res);
CMDBSource::FreeResult($res);
if ($bMustBeFound && empty($aRow)) {
throw new CoreException("No result for the single row query: '{$sSQL}'");
}
return $aRow;
}