本文整理汇总了PHP中QQ::CustomFrom方法的典型用法代码示例。如果您正苦于以下问题:PHP QQ::CustomFrom方法的具体用法?PHP QQ::CustomFrom怎么用?PHP QQ::CustomFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQ
的用法示例。
在下文中一共展示了QQ::CustomFrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PrepareQqForSearch
/**
* Given a search term, this will try and match all similarly matched individuals.
* This will utilize soundex and other indexing methodologies.
*
* @param string $strName
* @param QQCondition $objCondition
* @param QQClause[] $objClauses
* @param QQNodePerson $objPersonNode
* @return void
*/
public static function PrepareQqForSearch($strName, QQCondition &$objCondition, &$objClauses, QQNodePerson $objPersonNode = null)
{
if (!$objPersonNode) {
$objPersonNode = QQN::Person();
}
$strNameItemArray = NameItem::GetNormalizedArrayFromNameString($strName, true);
// First, get the applicable NameItem
$intNameItemIdArrayArray = array();
foreach ($strNameItemArray as $strNameItem) {
$intNameItemIdArray = array();
$strQuery = sprintf("SELECT * FROM name_item WHERE (soundex(name) = soundex('%s') OR name LIKE '%s%%')", mysql_escape_string($strNameItem), mysql_escape_string($strNameItem));
$objNameItemArray = NameItem::InstantiateDbResult(NameItem::GetDatabase()->Query($strQuery));
foreach ($objNameItemArray as $objNameItem) {
$intNameItemIdArray[] = $objNameItem->Id;
}
$intNameItemIdArrayArray[] = $intNameItemIdArray;
}
// Build the search array from Person
$intIndex = 0;
foreach ($intNameItemIdArrayArray as $intNameItemIdArray) {
if (!count($intNameItemIdArray)) {
$objCondition = QQ::None();
return;
}
$intIndex++;
$strAlias = 'assn_' . $intIndex;
if ($intIndex == 2) {
$objClauses[] = QQ::Distinct();
}
$objClauses[] = QQ::CustomFrom('person_nameitem_assn', $strAlias);
if (count($intNameItemIdArray) == 1) {
$objCondition = QQ::AndCondition($objCondition, QQ::Equal(QQ::CustomNode($strAlias . '.person_id'), $objPersonNode->Id), QQ::Equal(QQ::CustomNode($strAlias . '.name_item_id'), $intNameItemIdArray[0]));
} else {
$objCondition = QQ::AndCondition($objCondition, QQ::Equal(QQ::CustomNode($strAlias . '.person_id'), $objPersonNode->Id), QQ::In(QQ::CustomNode($strAlias . '.name_item_id'), $intNameItemIdArray));
}
}
}