本文整理汇总了PHP中MetaModel::PrepareQueryArguments方法的典型用法代码示例。如果您正苦于以下问题:PHP MetaModel::PrepareQueryArguments方法的具体用法?PHP MetaModel::PrepareQueryArguments怎么用?PHP MetaModel::PrepareQueryArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MetaModel
的用法示例。
在下文中一共展示了MetaModel::PrepareQueryArguments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MakeSelectQuery
/**
* @param hash $aOrderBy Array of '[<classalias>.]attcode' => bAscending
*/
public function MakeSelectQuery($aOrderBy = array(), $aArgs = array(), $aAttToLoad = null, $aExtendedDataSpec = null, $iLimitCount = 0, $iLimitStart = 0, $bGetCount = false)
{
// Check the order by specification, and prefix with the class alias
// and make sure that the ordering columns are going to be selected
//
$sClass = $this->GetClass();
$sClassAlias = $this->GetClassAlias();
$aOrderSpec = array();
foreach ($aOrderBy as $sFieldAlias => $bAscending) {
if (!is_bool($bAscending)) {
throw new CoreException("Wrong direction in ORDER BY spec, found '{$bAscending}' and expecting a boolean value");
}
$iDotPos = strpos($sFieldAlias, '.');
if ($iDotPos === false) {
$sAttClass = $sClass;
$sAttClassAlias = $sClassAlias;
$sAttCode = $sFieldAlias;
} else {
$sAttClassAlias = substr($sFieldAlias, 0, $iDotPos);
$sAttClass = $this->GetClassName($sAttClassAlias);
$sAttCode = substr($sFieldAlias, $iDotPos + 1);
}
if ($sAttCode != 'id') {
MyHelpers::CheckValueInArray('field name in ORDER BY spec', $sAttCode, MetaModel::GetAttributesList($sAttClass));
$oAttDef = MetaModel::GetAttributeDef($sAttClass, $sAttCode);
foreach ($oAttDef->GetOrderBySQLExpressions($sAttClassAlias) as $sSQLExpression) {
$aOrderSpec[$sSQLExpression] = $bAscending;
}
} else {
$aOrderSpec['`' . $sAttClassAlias . $sAttCode . '`'] = $bAscending;
}
// Make sure that the columns used for sorting are present in the loaded columns
if (!is_null($aAttToLoad) && !isset($aAttToLoad[$sAttClassAlias][$sAttCode])) {
$aAttToLoad[$sAttClassAlias][$sAttCode] = MetaModel::GetAttributeDef($sAttClass, $sAttCode);
}
}
$oSQLQuery = $this->GetSQLQuery($aOrderBy, $aArgs, $aAttToLoad, $aExtendedDataSpec, $iLimitCount, $iLimitStart, $bGetCount);
$aScalarArgs = array_merge(MetaModel::PrepareQueryArguments($aArgs), $this->GetInternalParams());
try {
$bBeautifulSQL = self::$m_bTraceQueries || self::$m_bDebugQuery || self::$m_bIndentQueries;
$sRes = $oSQLQuery->RenderSelect($aOrderSpec, $aScalarArgs, $iLimitCount, $iLimitStart, $bGetCount, $bBeautifulSQL);
if ($sClassAlias == '_itop_') {
IssueLog::Info('SQL Query (_itop_): ' . $sRes);
}
} catch (MissingQueryArgument $e) {
// Add some information...
$e->addInfo('OQL', $this->ToOQL());
throw $e;
}
$this->AddQueryTraceSelect($aOrderBy, $aArgs, $aAttToLoad, $aExtendedDataSpec, $iLimitCount, $iLimitStart, $bGetCount, $sRes);
return $sRes;
}
示例2: MakeUpdateQuery
public function MakeUpdateQuery($aValues, $aArgs = array())
{
// $aValues is an array of $sAttCode => $value
$aModifierProperties = MetaModel::MakeModifierProperties($this);
$oBuild = new QueryBuilderContext($this, $aModifierProperties);
$oSQLQuery = $this->MakeSQLObjectQuery($oBuild, null, $aValues);
$oSQLQuery->SetCondition($oBuild->m_oQBExpressions->GetCondition());
$oSQLQuery->SetSelect($oBuild->m_oQBExpressions->GetSelect());
$aScalarArgs = array_merge(MetaModel::PrepareQueryArguments($aArgs), $this->GetInternalParams());
return $oSQLQuery->RenderUpdate($aScalarArgs);
}
示例3: GetFilter
/**
* Retrieve the DBSearch corresponding to the objects present in this set
*
* Limitation:
* This method will NOT work for sets with several columns (i.e. several objects per row)
*
* @return DBObjectSearch
*/
public function GetFilter()
{
// Make sure that we carry on the parameters of the set with the filter
$oFilter = $this->m_oFilter->DeepClone();
// Note: the arguments found within a set can be object (but not in a filter)
// That's why PrepareQueryArguments must be invoked there
$oFilter->SetInternalParams(array_merge($oFilter->GetInternalParams(), MetaModel::PrepareQueryArguments($this->m_aArgs)));
if (count($this->m_aAddedIds) == 0) {
return $oFilter;
} else {
$oIdListExpr = ListExpression::FromScalars(array_keys($this->m_aAddedIds));
$oIdExpr = new FieldExpression('id', $oFilter->GetClassAlias());
$oIdInList = new BinaryExpression($oIdExpr, 'IN', $oIdListExpr);
$oFilter->MergeConditionExpression($oIdInList);
return $oFilter;
}
}
示例4: ToOQL
public function ToOQL($bDevelopParams = false, $aContextParams = null)
{
// Currently unused, but could be useful later
$bRetrofitParams = false;
if ($bDevelopParams) {
if (is_null($aContextParams)) {
$aParams = array_merge($this->m_aParams);
} else {
$aParams = array_merge($aContextParams, $this->m_aParams);
}
$aParams = MetaModel::PrepareQueryArguments($aParams);
} else {
// Leave it as is, the rendering will be made with parameters in clear
$aParams = null;
}
$sSelectedClasses = implode(', ', array_keys($this->m_aSelectedClasses));
$sRes = 'SELECT ' . $sSelectedClasses . ' FROM';
$sRes .= ' ' . $this->GetFirstJoinedClass() . ' AS ' . $this->GetFirstJoinedClassAlias();
$sRes .= $this->ToOQL_Joins();
$sRes .= " WHERE " . $this->m_oSearchCondition->Render($aParams, $bRetrofitParams);
// Temporary: add more info about other conditions, necessary to avoid strange behaviors with the cache
foreach ($this->m_aFullText as $sFullText) {
$sRes .= " AND MATCHES '{$sFullText}'";
}
return $sRes;
}