当前位置: 首页>>代码示例>>PHP>>正文


PHP Comments::fetch方法代码示例

本文整理汇总了PHP中Comments::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP Comments::fetch方法的具体用法?PHP Comments::fetch怎么用?PHP Comments::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Comments的用法示例。


在下文中一共展示了Comments::fetch方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getReviewTitles

 private function _getReviewTitles($reviewTag)
 {
     //Load a list of reviews based on the tag
     $comments = new Comments();
     $comments->whereAdd("comment like \"%#" . mysql_escape_string($reviewTag) . '"');
     $comments->find();
     $recordIds = array();
     $reviews = array();
     $datesSaved = array();
     while ($comments->fetch()) {
         $resourceId = $comments->resource_id;
         //Load the resource from the database
         $resource = new Resource();
         $resource->id = $comments->resource_id;
         $resource->find(true);
         $recordIds[$resource->record_id] = $resource->record_id;
         $comment = preg_replace('/#.*/', '', $comments->comment);
         $reviews[$resource->record_id] = $comment;
         $datesSaved[$resource->record_id] = $comments->created;
     }
     $titles = $this->loadTitleInformationForIds($recordIds, $reviews, $datesSaved);
     return array('success' => true, 'listName' => $reviewTag, 'listDescription' => 'Tagged reviews', 'titles' => $titles, 'cacheLength' => 24);
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:23,代码来源:ListAPI.php

示例2: getComments

 /**
  * @param string $source
  * @return array
  */
 function getComments($source = 'VuFind')
 {
     require_once ROOT_DIR . '/services/MyResearch/lib/Comments.php';
     $sql = "SELECT comments.*, CONCAT(LEFT(user.firstname,1), '. ', user.lastname) as fullname, user.displayName as displayName " . "FROM comments RIGHT OUTER JOIN user on comments.user_id = user.id " . "WHERE comments.resource_id = '{$this->id}' ORDER BY comments.created";
     //Get a reference to the scope we are in so we can determine how to process the comments.
     global $library;
     global $user;
     //Load all bad words.
     require_once ROOT_DIR . '/Drivers/marmot_inc/BadWord.php';
     $badWords = new BadWord();
     $badWordsList = $badWords->getBadWordExpressions();
     $commentList = array();
     $commentList['user'] = array();
     $commentList['staff'] = array();
     $comment = new Comments();
     $comment->query($sql);
     if ($comment->N) {
         while ($comment->fetch()) {
             $okToAdd = true;
             if (isset($user) && $user != false && $user->id == $comment->user_id) {
                 //It's always ok to show the user what they wrote
             } else {
                 //Determine if we should censor bad words or hide the comment completely.
                 $censorWords = true;
                 if (isset($library)) {
                     $censorWords = $library->hideCommentsWithBadWords == 0 ? true : false;
                 }
                 if ($censorWords) {
                     $commentText = $comment->comment;
                     foreach ($badWordsList as $badWord) {
                         $commentText = preg_replace($badWord, '***', $commentText);
                     }
                     $comment->comment = $commentText;
                 } else {
                     //Remove comments with bad words
                     $commentText = trim($comment->comment);
                     foreach ($badWordsList as $badWord) {
                         if (preg_match($badWord, $commentText)) {
                             $okToAdd = false;
                             break;
                         }
                     }
                 }
             }
             if ($okToAdd) {
                 //Remove any hashtags that were added to the review.
                 if (preg_match('/#.*/', $comment->comment)) {
                     $comment->comment = preg_replace('/#.*/', '', $comment->comment);
                     $commentList['staff'][] = clone $comment;
                 } else {
                     $commentList['user'][] = clone $comment;
                 }
             }
         }
     }
     return $commentList;
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:61,代码来源:Resource.php

示例3: readConfig

$configArray = readConfig();
// Setup time zone
date_default_timezone_set($configArray['Site']['timezone']);
// Setup Local Database Connection
ConnectionManager::connectToDatabase();
// Setup index connection
ConnectionManager::connectToIndex();
// Delete the expired searches -- this cleans up any junk left in the database
// from old search histories that were not caught by the session garbage collector.
$count = 0;
$fixed = 0;
$searchObject = SearchObjectFactory::initSearchObject();
$searchObject->disableLogging();
$comments = new Comments();
if ($comments->find()) {
    while ($comments->fetch()) {
        $commentsRecord = new Comments_record();
        $commentsRecord->comment_id = $comments->id;
        if ($commentsRecord->find(true)) {
            $query = 'local_ids_str_mv:"' . addcslashes($commentsRecord->record_id, '"') . '"';
            $searchObject->setQueryString($query);
            $result = $searchObject->processSearch();
            $searchObject->close();
            if (PEAR::isError($result)) {
                PEAR::raiseError($result->getMessage());
            }
            if ($result['response']['numFound'] > 0) {
                $idArray = $result['response']['docs'][0]["local_ids_str_mv"];
                if ($comments->verifyLinks($idArray)) {
                    ++$fixed;
                }
开发者ID:bharatm,项目名称:NDL-VuFind,代码行数:31,代码来源:verify_record_links.php


注:本文中的Comments::fetch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。