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


PHP vB_Search_Core::get_db方法代码示例

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


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

示例1: indexQueue

 /**
 * vb_Search_Indexcontroller_Queue::indexQueue()
 *
 * Index an item based on a map of fieldname/value pairs
 *
 * @param string $package : the package which we are indexing
 * @param string $contenttype : text string with the type of content
 * @param string $operation: the index action, which will vary depending on the action.
 *    usually it will just be "index"
 * @param data : If we have fourth parameter we take it as an associative array of field values
 * @return : boolean success indicator
 */
 public static function indexQueue($package, $contenttype, $operation)
 {
     $data = array_slice(func_get_args(), 3);
     global $vbulletin;
     $db = vB_Search_Core::get_db();
     //For now we need to compose an sql query. Parameters are not available.
     //First make sure we've got good data. If we don't have the three parameters
     if (isset($package)) {
         $dbfields['package'] = "'" . $db->escape_string($package) . "'";
     } else {
         return false;
     }
     if (isset($contenttype)) {
         $dbfields['contenttype'] = "'" . $db->escape_string($contenttype) . "'";
     } else {
         return false;
     }
     if (isset($operation)) {
         $dbfields['operation'] = "'" . $db->escape_string($operation) . "'";
     }
     if (!$vbulletin->options['searchqueueupdates']) {
         // we just call indexNow. It checks for valid data.
         return vB_Search_Indexcontroller_QueueProcessor::indexNow($package, $contenttype, $operation, $data);
     }
     $dbfields['data'] = "'" . $db->escape_string(serialize($data)) . "'";
     $sql = "INSERT INTO " . TABLE_PREFIX . "indexqueue (" . implode(', ', array_keys($dbfields)) . ")\n\t\t\tVALUES ( " . implode(', ', $dbfields) . " )";
     $db->query_write($sql);
     return true;
 }
开发者ID:0hyeah,项目名称:yurivn,代码行数:41,代码来源:queue.php

示例2: index

    /**
     * vB_Search_Indexcontroller_QueueProcessor::index()
     * This is the default method. We get called by the cron job, and we have
     * no idea how many records are waiting, etc.
     *
     * @return : boolean success indicator
     */
    public static function index()
    {
        //first, do a check to see if we are unique. If we are already running,
        // we just quit.
        global $vbulletin;
        $lock_name = TABLE_PREFIX . 'vb_queue_lock';
        if (!($row = $vbulletin->db->query_first("SELECT IS_FREE_LOCK('{$lock_name}')"))) {
            error_log('in vB_Search_Indexcontroller_QueueProcessor::index,
				unable to query lock to do queue indexing');
            return false;
        }
        reset($row);
        if (!current($row)) {
            return false;
        }
        if (!($row = $vbulletin->db->query_first("SELECT GET_LOCK('{$lock_name}', 2)"))) {
            return false;
        }
        if (!current($row)) {
            return false;
        }
        //if we got here, we were able to get the lock.
        $vb = vB_Search_Core::get_instance();
        $db = vB_Search_Core::get_db();
        $rst = $db->query_read("SELECT indexqueue.* FROM " . TABLE_PREFIX . "indexqueue AS indexqueue ORDER BY queueid");
        $ids = array();
        $currtime = gettimeofday(true);
        $timeout = ini_get('max_execution_time');
        if ($timeout < 15 or $timeout > 300) {
            $timeout = 60;
            @set_time_limit($timeout);
        }
        $endtime = $currtime + intval($timeout * 0.75);
        while ($row = $db->fetch_array($rst)) {
            //make sure we have good data
            if ($row['contenttype'] == null || $row['package'] == null) {
                continue;
            }
            //let's try to get the correct controller
            if (($indexcontroller = $vb->get_index_controller($row['package'], $row['contenttype'])) == null) {
                continue;
            }
            if (gettimeofday(true) > $endtime) {
                break;
            }
            //The data is serialized, so let's extract it.
            $row['data'] = unserialize($row['data']);
            if (!self::indexOne($indexcontroller, $row['contenttype'], $row['operation'], $row['data'])) {
                error_log('Unable to index ' . ': ' . $row['operation'] . ': ' . isset($row['data'][0]) ? $row['data'][0] : '');
            }
            $ids[] = $row['queueid'];
        }
        if (count($ids)) {
            $db->query_write("DELETE from " . TABLE_PREFIX . "indexqueue WHERE queueid in(" . implode(', ', $ids) . ")");
        }
        $vbulletin->db->query_first("SELECT RELEASE_LOCK('{$lock_name}')");
        return true;
    }
开发者ID:0hyeah,项目名称:yurivn,代码行数:65,代码来源:queueprocessor.php


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