本文整理汇总了PHP中Forum::InstantiateDbRow方法的典型用法代码示例。如果您正苦于以下问题:PHP Forum::InstantiateDbRow方法的具体用法?PHP Forum::InstantiateDbRow怎么用?PHP Forum::InstantiateDbRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Forum
的用法示例。
在下文中一共展示了Forum::InstantiateDbRow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: InstantiateCursor
/**
* Instantiate a single Forum object from a query cursor (e.g. a DB ResultSet).
* Cursor is automatically moved to the "next row" of the result set.
* Will return NULL if no cursor or if the cursor has no more rows in the resultset.
* @param QDatabaseResultBase $objDbResult cursor resource
* @return Forum next row resulting from the query
*/
public static function InstantiateCursor(QDatabaseResultBase $objDbResult)
{
// If blank resultset, then return empty result
if (!$objDbResult) {
return null;
}
// If empty resultset, then return empty result
$objDbRow = $objDbResult->GetNextRow();
if (!$objDbRow) {
return null;
}
// We need the Column Aliases
$strColumnAliasArray = $objDbResult->QueryBuilder->ColumnAliasArray;
if (!$strColumnAliasArray) {
$strColumnAliasArray = array();
}
// Pull Expansions (if applicable)
$strExpandAsArrayNodes = $objDbResult->QueryBuilder->ExpandAsArrayNodes;
// Load up the return result with a row and return it
return Forum::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, null, $strColumnAliasArray);
}
示例2: InstantiateDbRow
/**
* Instantiate a TopicLink from a Database Row.
* Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
* is calling this TopicLink::InstantiateDbRow in order to perform
* early binding on referenced objects.
* @param QDatabaseRowBase $objDbRow
* @param string $strAliasPrefix
* @param string $strExpandAsArrayNodes
* @param QBaseClass $objPreviousItem
* @param string[] $strColumnAliasArray
* @return TopicLink
*/
public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $objPreviousItem = null, $strColumnAliasArray = array())
{
// If blank row, return null
if (!$objDbRow) {
return null;
}
// See if we're doing an array expansion on the previous item
$strAlias = $strAliasPrefix . 'id';
$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
if ($strExpandAsArrayNodes && $objPreviousItem && $objPreviousItem->intId == $objDbRow->GetColumn($strAliasName, 'Integer')) {
// We are. Now, prepare to check for ExpandAsArray clauses
$blnExpandedViaArray = false;
if (!$strAliasPrefix) {
$strAliasPrefix = 'topic_link__';
}
$strAlias = $strAliasPrefix . 'message__id';
$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
if (array_key_exists($strAlias, $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasName))) {
if ($intPreviousChildItemCount = count($objPreviousItem->_objMessageArray)) {
$objPreviousChildItem = $objPreviousItem->_objMessageArray[$intPreviousChildItemCount - 1];
$objChildItem = Message::InstantiateDbRow($objDbRow, $strAliasPrefix . 'message__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
if ($objChildItem) {
$objPreviousItem->_objMessageArray[] = $objChildItem;
}
} else {
$objPreviousItem->_objMessageArray[] = Message::InstantiateDbRow($objDbRow, $strAliasPrefix . 'message__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
}
$blnExpandedViaArray = true;
}
$strAlias = $strAliasPrefix . 'topic__id';
$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
if (array_key_exists($strAlias, $strExpandAsArrayNodes) && !is_null($objDbRow->GetColumn($strAliasName))) {
if ($intPreviousChildItemCount = count($objPreviousItem->_objTopicArray)) {
$objPreviousChildItem = $objPreviousItem->_objTopicArray[$intPreviousChildItemCount - 1];
$objChildItem = Topic::InstantiateDbRow($objDbRow, $strAliasPrefix . 'topic__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
if ($objChildItem) {
$objPreviousItem->_objTopicArray[] = $objChildItem;
}
} else {
$objPreviousItem->_objTopicArray[] = Topic::InstantiateDbRow($objDbRow, $strAliasPrefix . 'topic__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
}
$blnExpandedViaArray = true;
}
// Either return false to signal array expansion, or check-to-reset the Alias prefix and move on
if ($blnExpandedViaArray) {
return false;
} else {
if ($strAliasPrefix == 'topic_link__') {
$strAliasPrefix = null;
}
}
}
// Create a new instance of the TopicLink object
$objToReturn = new TopicLink();
$objToReturn->__blnRestored = true;
$strAliasName = array_key_exists($strAliasPrefix . 'id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'id'] : $strAliasPrefix . 'id';
$objToReturn->intId = $objDbRow->GetColumn($strAliasName, 'Integer');
$strAliasName = array_key_exists($strAliasPrefix . 'topic_link_type_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'topic_link_type_id'] : $strAliasPrefix . 'topic_link_type_id';
$objToReturn->intTopicLinkTypeId = $objDbRow->GetColumn($strAliasName, 'Integer');
$strAliasName = array_key_exists($strAliasPrefix . 'topic_count', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'topic_count'] : $strAliasPrefix . 'topic_count';
$objToReturn->intTopicCount = $objDbRow->GetColumn($strAliasName, 'Integer');
$strAliasName = array_key_exists($strAliasPrefix . 'message_count', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'message_count'] : $strAliasPrefix . 'message_count';
$objToReturn->intMessageCount = $objDbRow->GetColumn($strAliasName, 'Integer');
$strAliasName = array_key_exists($strAliasPrefix . 'last_post_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'last_post_date'] : $strAliasPrefix . 'last_post_date';
$objToReturn->dttLastPostDate = $objDbRow->GetColumn($strAliasName, 'DateTime');
$strAliasName = array_key_exists($strAliasPrefix . 'forum_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'forum_id'] : $strAliasPrefix . 'forum_id';
$objToReturn->intForumId = $objDbRow->GetColumn($strAliasName, 'Integer');
$strAliasName = array_key_exists($strAliasPrefix . 'issue_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'issue_id'] : $strAliasPrefix . 'issue_id';
$objToReturn->intIssueId = $objDbRow->GetColumn($strAliasName, 'Integer');
$strAliasName = array_key_exists($strAliasPrefix . 'wiki_item_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'wiki_item_id'] : $strAliasPrefix . 'wiki_item_id';
$objToReturn->intWikiItemId = $objDbRow->GetColumn($strAliasName, 'Integer');
$strAliasName = array_key_exists($strAliasPrefix . 'package_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'package_id'] : $strAliasPrefix . 'package_id';
$objToReturn->intPackageId = $objDbRow->GetColumn($strAliasName, 'Integer');
// Instantiate Virtual Attributes
foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
$strVirtualPrefix = $strAliasPrefix . '__';
$strVirtualPrefixLength = strlen($strVirtualPrefix);
if (substr($strColumnName, 0, $strVirtualPrefixLength) == $strVirtualPrefix) {
$objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
}
}
// Prepare to Check for Early/Virtual Binding
if (!$strAliasPrefix) {
$strAliasPrefix = 'topic_link__';
}
// Check for Forum Early Binding
$strAlias = $strAliasPrefix . 'forum_id__id';
$strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
//.........这里部分代码省略.........
示例3: InstantiateDbResult
/**
* Instantiate an array of Forums from a Database Result
* @param DatabaseResultBase $objDbResult
* @param string $strExpandAsArrayNodes
* @param string[] $strColumnAliasArray
* @return Forum[]
*/
public static function InstantiateDbResult(QDatabaseResultBase $objDbResult, $strExpandAsArrayNodes = null, $strColumnAliasArray = null)
{
$objToReturn = array();
if (!$strColumnAliasArray) {
$strColumnAliasArray = array();
}
// If blank resultset, then return empty array
if (!$objDbResult) {
return $objToReturn;
}
// Load up the return array with each row
if ($strExpandAsArrayNodes) {
$objLastRowItem = null;
while ($objDbRow = $objDbResult->GetNextRow()) {
$objItem = Forum::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objLastRowItem, $strColumnAliasArray);
if ($objItem) {
$objToReturn[] = $objItem;
$objLastRowItem = $objItem;
}
}
} else {
while ($objDbRow = $objDbResult->GetNextRow()) {
$objToReturn[] = Forum::InstantiateDbRow($objDbRow, null, null, null, $strColumnAliasArray);
}
}
return $objToReturn;
}