本文整理汇总了PHP中Topic::GetDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP Topic::GetDatabase方法的具体用法?PHP Topic::GetDatabase怎么用?PHP Topic::GetDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topic
的用法示例。
在下文中一共展示了Topic::GetDatabase方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UnassociateAllPeopleAsRead
/**
* Unassociates all PeopleAsRead
* @return void
*/
public function UnassociateAllPeopleAsRead()
{
if (is_null($this->intId)) {
throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAllPersonAsReadArray on this unsaved Topic.');
}
// Get the Database Object for this Class
$objDatabase = Topic::GetDatabase();
// Perform the SQL Query
$objDatabase->NonQuery('
DELETE FROM
`read_topic_person_assn`
WHERE
`topic_id` = ' . $objDatabase->SqlVariable($this->intId) . '
');
}
示例2: GetPageNumber
/**
* Given a Topic and the number of items in a "page", this will
* return the page number that the topic shows up in
* when listing all topics for the Topic's forum, assuming
* the list of topics is ordered by reverse last_post_date
* @param Topic $objTopic the topic to search for
* @param integer $intItemsPerPage
* @param Zend_Search_Lucene_Search_QueryHit[] $objQueryHitArray a predefined set of topics to search through
* @return unknown_type
*/
public function GetPageNumber(Topic $objTopic, $intItemsPerPage, $objQueryHitArray = null)
{
if (is_null($objQueryHitArray)) {
$objResult = Topic::GetDatabase()->Query('SELECT id FROM topic WHERE topic_link_id=' . $objTopic->TopicLinkId . ' ORDER BY last_post_date DESC');
$intRecordNumber = 0;
while ($objRow = $objResult->GetNextRow()) {
$intRecordNumber++;
if ($objRow->GetColumn('id') == $objTopic->Id) {
break;
}
}
} else {
$intRecordNumber = 0;
foreach ($objQueryHitArray as $objHit) {
$intRecordNumber++;
if ($objHit->db_id == $objTopic->Id) {
break;
}
}
}
$intPageNumber = floor($intRecordNumber / $intItemsPerPage);
if ($intRecordNumber % $intItemsPerPage) {
$intPageNumber++;
}
return $intPageNumber;
}
示例3: LoadArrayBySearch
/**
* Searches using the search index for applicable topics, and returns topics as an array
* Note that this will return ALL topics for the search. No limit / pagination can be applied.
* @param string $strSearchQuery
* @return Topic[]
*/
public static function LoadArrayBySearch($strSearchQuery)
{
// open the index
$objIndex = new Zend_Search_Lucene(__SEARCH_INDEXES__ . '/topics');
$intIdArray = array();
$objHits = $objIndex->find($strSearchQuery);
if (!count($objHits)) {
return array();
}
foreach ($objHits as $objHit) {
$intIdArray[] = $objHit->db_id;
// note: do we want to do anything with $objHit->score (?)
}
$objResult = Topic::GetDatabase()->Query('SELECT * FROM topic WHERE id IN(' . implode(',', $intIdArray) . ');');
while ($objRow = $objResult->GetNextRow()) {
$objTopic = Topic::InstantiateDbRow($objRow);
$objTopicArrayById[$objTopic->Id] = $objTopic;
}
$objTopicArray = array();
foreach ($objHits as $objHit) {
$objTopicArray[] = $objTopicArrayById[intval($objHit->db_id)];
}
return $objTopicArray;
}
示例4: array
$objWikiPage->CompileHtml();
$objWikiItem->CreateNewVersion('Downloads from Old Qcodo.com Website', $objWikiPage, 'Save', array(), Person::Load(1), null);
print "Done.\r\n";
QDataGen::DisplayForEachTaskStart($strTitle = 'Refreshing Topic Stats', Topic::CountAll());
foreach (Topic::LoadAll() as $objTopic) {
QDataGen::DisplayForEachTaskNext($strTitle);
$objTopic->RefreshStats();
}
QDataGen::DisplayForEachTaskEnd($strTitle);
QDataGen::DisplayForEachTaskStart($strTitle = 'Refreshing TopicLink Stats', TopicLink::CountAll());
foreach (TopicLink::LoadAll() as $objTopicLink) {
QDataGen::DisplayForEachTaskNext($strTitle);
$objTopicLink->RefreshStats();
}
QDataGen::DisplayForEachTaskEnd($strTitle);
$objResult = $objDb->query('SELECT * FROM email_topic_person_assn');
while (QDataGen::DisplayWhileTask('Migrating email_topic_person_assn', $objResult->num_rows)) {
$objRow = $objResult->fetch_array();
try {
Topic::GetDatabase()->NonQuery('INSERT INTO email_topic_person_assn(topic_id, person_id) VALUES (' . $objRow['topic_id'] . ',' . $objRow['person_id'] . ');');
} catch (QMySqliDatabaseException $objExc) {
}
}
$objResult = $objDb->query('SELECT * FROM read_topic_person_assn');
while (QDataGen::DisplayWhileTask('Migrating read_topic_person_assn', $objResult->num_rows)) {
$objRow = $objResult->fetch_array();
try {
Topic::GetDatabase()->NonQuery('INSERT INTO read_topic_person_assn(topic_id, person_id) VALUES (' . $objRow['topic_id'] . ',' . $objRow['person_id'] . ');');
} catch (QMySqliDatabaseException $objExc) {
}
}
示例5: UnassociateAllPeopleAsRead
/**
* Unassociates all PeopleAsRead
* @return void
*/
public function UnassociateAllPeopleAsRead()
{
if (is_null($this->intId)) {
throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAllPersonAsReadArray on this unsaved Topic.');
}
// Get the Database Object for this Class
$objDatabase = Topic::GetDatabase();
// Journaling (if applicable)
if ($objDatabase->JournalingDatabase) {
$objResult = $objDatabase->Query('SELECT `person_id` AS associated_id FROM `read_topic_person_assn` WHERE `topic_id` = ' . $objDatabase->SqlVariable($this->intId));
while ($objRow = $objResult->GetNextRow()) {
$this->JournalPersonAsReadAssociation($objRow->GetColumn('associated_id'), 'DELETE');
}
}
// Perform the SQL Query
$objDatabase->NonQuery('
DELETE FROM
`read_topic_person_assn`
WHERE
`topic_id` = ' . $objDatabase->SqlVariable($this->intId) . '
');
}