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


PHP qa_db_connect函数代码示例

本文整理汇总了PHP中qa_db_connect函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_db_connect函数的具体用法?PHP qa_db_connect怎么用?PHP qa_db_connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: qa_db_connection

function qa_db_connection()
{
    global $qa_db;
    if (!is_resource($qa_db)) {
        qa_db_connect();
        if (!is_resource($qa_db)) {
            qa_fatal_error('Failed to connect to database');
        }
    }
    return $qa_db;
}
开发者ID:TheProjecter,项目名称:microprobe,代码行数:11,代码来源:qa-db.php

示例2: get_cache

 /**
  * Outputs cache to the user
  */
 private function get_cache()
 {
     qa_report_process_stage('init_page');
     qa_db_connect('qa_page_db_fail_handler');
     qa_page_queue_pending();
     qa_load_state();
     qa_check_login_modules();
     if (QA_DEBUG_PERFORMANCE) {
         if (qa_qa_version_below('1.7')) {
             qa_usage_mark('setup');
         } else {
             //global $qa_usage;
             //$qa_usage->mark('setup');
             null;
         }
     }
     qa_check_page_clicks();
     qa_set_form_security_key();
     if (!QA_CACHING_FILE) {
         $contents = $this->get_cache_db();
     } else {
         $contents = $this->get_cache_file();
     }
     $qa_content = array();
     // Dummy contents
     $userid = qa_get_logged_in_userid();
     $questionid = qa_request_part(0);
     $cookieid = qa_cookie_get(true);
     if (is_numeric($questionid)) {
         $question = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $questionid));
         if (is_numeric($questionid) && qa_opt('do_count_q_views') && !preg_match("/^(?:POST|PUT)\$/i", $_SERVER["REQUEST_METHOD"]) && !qa_is_http_post() && qa_is_human_probably() && (!$question['views'] || ($question['lastviewip'] != qa_remote_ip_address() || !isset($question['lastviewip'])) && ($question['createip'] != qa_remote_ip_address() || !isset($question['createip'])) && ($question['userid'] != $userid || !isset($question['userid'])) && ($question['cookieid'] != $cookieid || !isset($question['cookieid'])))) {
             $qa_content['inc_views_postid'] = $questionid;
         } else {
             $qa_content['inc_views_postid'] = null;
         }
         qa_do_content_stats($qa_content);
     }
     if (QA_DEBUG_PERFORMANCE) {
         ob_start();
         if (qa_qa_version_below('1.7')) {
             qa_usage_output();
         } else {
             global $qa_usage;
             $qa_usage->output();
         }
         $contents .= ob_get_contents();
         ob_end_clean();
     }
     qa_db_disconnect();
     header('Content-type: ' . strtr('^type/^format; charset=utf-8', array('^type' => 'text', '^format' => $this->get_cache_file_extension())));
     exit($contents);
 }
开发者ID:amiyasahu,项目名称:q2a-caching,代码行数:55,代码来源:qa-caching-main.php

示例3: qa_exit

    qa_exit();
}
function qa_feed_load_ifcategory($categoryslugs, $allkey, $catkey, &$title, $questionselectspec1 = null, $questionselectspec2 = null, $questionselectspec3 = null, $questionselectspec4 = null)
{
    $countslugs = @count($categoryslugs);
    list($questions1, $questions2, $questions3, $questions4, $categories, $categoryid) = qa_db_select_with_pending($questionselectspec1, $questionselectspec2, $questionselectspec3, $questionselectspec4, $countslugs ? qa_db_category_nav_selectspec($categoryslugs, false) : null, $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null);
    if ($countslugs && !isset($categoryid)) {
        qa_feed_not_found();
    }
    if (isset($allkey)) {
        $title = isset($categoryid) && isset($catkey) ? qa_lang_sub($catkey, $categories[$categoryid]['title']) : qa_lang($allkey);
    }
    return array_merge(is_array($questions1) ? $questions1 : array(), is_array($questions2) ? $questions2 : array(), is_array($questions3) ? $questions3 : array(), is_array($questions4) ? $questions4 : array());
}
//	Connect to database and get the type of feed and category requested (in some cases these are overridden later)
qa_db_connect('qa_feed_db_fail_handler');
qa_preload_options();
$requestlower = strtolower(qa_request());
$foursuffix = substr($requestlower, -4);
if ($foursuffix == '.rss' || $foursuffix == '.xml') {
    $requestlower = substr($requestlower, 0, -4);
}
$requestlowerparts = explode('/', $requestlower);
$feedtype = @$requestlowerparts[1];
$feedparams = array_slice($requestlowerparts, 2);
//	Choose which option needs to be checked to determine if this feed can be requested, and stop if no matches
$feedoption = null;
$categoryslugs = $feedparams;
switch ($feedtype) {
    case 'questions':
        $feedoption = 'feed_for_questions';
开发者ID:swuit,项目名称:swuit-q2a,代码行数:31,代码来源:qa-feed.php

示例4: qa_image_db_fail_handler

	More about this license: http://www.question2answer.org/license.php
*/
//	Ensure no PHP errors are shown in the image data
@ini_set('display_errors', 0);
function qa_image_db_fail_handler()
{
    header('HTTP/1.1 500 Internal Server Error');
    qa_exit('error');
}
//	Load the Q2A base file which sets up a bunch of crucial stuff
require 'qa-base.php';
qa_report_process_stage('init_image');
//	Retrieve the scaled image from the cache if available
require_once QA_INCLUDE_DIR . 'qa-db-cache.php';
qa_db_connect('qa_image_db_fail_handler');
$blobid = qa_get('qa_blobid');
$size = (int) qa_get('qa_size');
$cachetype = 'i_' . $size;
$content = qa_db_cache_get($cachetype, $blobid);
// see if we've cached the scaled down version
header('Cache-Control: max-age=2592000, public');
// allows browsers and proxies to cache images too
if (isset($content)) {
    header('Content-Type: image/jpeg');
    echo $content;
} else {
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    require_once QA_INCLUDE_DIR . 'qa-app-blobs.php';
    require_once QA_INCLUDE_DIR . 'qa-util-image.php';
    //	Otherwise retrieve the raw image and scale as appropriate
开发者ID:gogupe,项目名称:question2answer-releases,代码行数:30,代码来源:qa-image.php

示例5: qa_blob_db_fail_handler

	More about this license: http://www.question2answer.org/license.php
*/
//	Ensure no PHP errors are shown in the blob response
@ini_set('display_errors', 0);
function qa_blob_db_fail_handler()
{
    header('HTTP/1.1 500 Internal Server Error');
    qa_exit('error');
}
//	Load the Q2A base file which sets up a bunch of crucial stuff
require 'qa-base.php';
qa_report_process_stage('init_blob');
//	Output the blob in question
require_once QA_INCLUDE_DIR . 'app/blobs.php';
qa_db_connect('qa_blob_db_fail_handler');
$blob = qa_read_blob(qa_get('qa_blobid'));
if (isset($blob)) {
    header('Cache-Control: max-age=2592000, public');
    // allows browsers and proxies to cache the blob
    switch ($blob['format']) {
        case 'jpeg':
        case 'jpg':
            header('Content-Type: image/jpeg');
            break;
        case 'gif':
            header('Content-Type: image/gif');
            break;
        case 'png':
            header('Content-Type: image/png');
            break;
开发者ID:ronkeizer,项目名称:question2answer,代码行数:30,代码来源:qa-blob.php

示例6: header

	More about this license: http://www.question2answer.org/license.php
*/
//	Output this header as early as possible
header('Content-Type: text/plain; charset=utf-8');
//	Ensure no PHP errors are shown in the Ajax response
@ini_set('display_errors', 0);
//	Load the Q2A base file which sets up a bunch of crucial functions
require 'qa-base.php';
qa_report_process_stage('init_ajax');
//	Get general Ajax parameters from the POST payload, and clear $_GET
qa_set_request(qa_post_text('qa_request'), qa_post_text('qa_root'));
$_GET = array();
// for qa_self_html()
//	Database failure handler
function qa_ajax_db_fail_handler()
{
    echo "QA_AJAX_RESPONSE\n0\nA database error occurred.";
    qa_exit('error');
}
//	Perform the appropriate Ajax operation
$routing = array('notice' => 'qa-ajax-notice.php', 'favorite' => 'qa-ajax-favorite.php', 'vote' => 'qa-ajax-vote.php', 'recalc' => 'qa-ajax-recalc.php', 'mailing' => 'qa-ajax-mailing.php', 'version' => 'qa-ajax-version.php', 'category' => 'qa-ajax-category.php', 'asktitle' => 'qa-ajax-asktitle.php', 'answer' => 'qa-ajax-answer.php', 'comment' => 'qa-ajax-comment.php', 'click_a' => 'qa-ajax-click-answer.php', 'click_c' => 'qa-ajax-click-comment.php', 'click_admin' => 'qa-ajax-click-admin.php', 'show_cs' => 'qa-ajax-show-comments.php', 'wallpost' => 'qa-ajax-wallpost.php', 'click_wall' => 'qa-ajax-click-wall.php');
$operation = qa_post_text('qa_operation');
if (isset($routing[$operation])) {
    qa_db_connect('qa_ajax_db_fail_handler');
    require QA_INCLUDE_DIR . $routing[$operation];
    qa_db_disconnect();
}
/*
	Omit PHP closing tag to help avoid accidental output
*/
开发者ID:gogupe,项目名称:question2answer-releases,代码行数:30,代码来源:qa-ajax.php

示例7: qa_db_connection

/**
 * Return the current connection to the Q2A database, connecting if necessary and $connect is true.
 */
function qa_db_connection($connect = true)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    global $qa_db_connection;
    if ($connect && !$qa_db_connection instanceof mysqli) {
        qa_db_connect();
        if (!$qa_db_connection instanceof mysqli) {
            qa_fatal_error('Failed to connect to database');
        }
    }
    return $qa_db_connection;
}
开发者ID:ronkeizer,项目名称:question2answer,代码行数:18,代码来源:qa-db.php

示例8: qa_html

            break;
        case 'select':
            $errorhtml .= 'Could not switch to the Question2Answer database. Please check the database name in the config file, and if necessary create the database in MySQL and grant appropriate user privileges.';
            break;
        case 'query':
            global $pass_failure_from_install;
            if (@$pass_failure_from_install) {
                $errorhtml .= "Question2Answer was unable to perform the installation query below. Please check the user in the config file has CREATE and ALTER permissions:\n\n" . qa_html($pass_failure_query . "\n\nError " . $pass_failure_errno . ": " . $pass_failure_error . "\n\n");
            } else {
                $errorhtml .= "A Question2Answer database query failed when generating this page.\n\nA full description of the failure is available in the web server's error log file.";
            }
            break;
    }
} else {
    // this page was requested by user GET/POST, so handle any incoming clicks on buttons
    qa_db_connect('qa_install_db_fail_handler');
    if (qa_clicked('create')) {
        qa_db_install_tables();
        if (QA_FINAL_EXTERNAL_USERS) {
            if (defined('QA_FINAL_WORDPRESS_INTEGRATE_PATH')) {
                require_once QA_INCLUDE_DIR . 'qa-db-admin.php';
                require_once QA_INCLUDE_DIR . 'qa-app-format.php';
                qa_db_page_move(qa_db_page_create(get_option('blogname'), QA_PAGE_FLAGS_EXTERNAL, get_option('home'), null, null, null), 'O', 1);
                // create link back to WordPress home page
                $success .= 'Your Question2Answer database has been created and integrated with your WordPress site.';
            } else {
                $success .= 'Your Question2Answer database has been created for external user identity management. Please read the online documentation to complete integration.';
            }
        } else {
            $success .= 'Your Question2Answer database has been created.';
        }
开发者ID:mostafiz93,项目名称:PrintfScanf,代码行数:31,代码来源:qa-install.php

示例9: get_cache

 /**
  * Outputs cache to the user
  */
 private function get_cache()
 {
     global $qa_usage;
     qa_db_connect('qa_page_db_fail_handler');
     qa_page_queue_pending();
     qa_load_state();
     qa_check_login_modules();
     qa_check_page_clicks();
     $contents = @file_get_contents($this->cache_file);
     if (!$contents) {
         return;
     }
     //cache failure, graceful exit
     $qa_content = array();
     // Dummy contents
     $userid = qa_get_logged_in_userid();
     $questionid = qa_request_part(0);
     $cookieid = qa_cookie_get(true);
     if (is_numeric($questionid)) {
         $question = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $questionid));
         if (is_numeric($questionid) && qa_opt('do_count_q_views') && !$this->post_method && !qa_is_http_post() && qa_is_human_probably() && (!$question['views'] || ($question['lastviewip'] != qa_remote_ip_address() || !isset($question['lastviewip'])) && ($question['createip'] != qa_remote_ip_address() || !isset($question['createip'])) && ($question['userid'] != $userid || !isset($question['userid'])) && ($question['cookieid'] != $cookieid || !isset($question['cookieid'])))) {
             $qa_content['inc_views_postid'] = $questionid;
         } else {
             $qa_content['inc_views_postid'] = null;
         }
         qa_do_content_stats($qa_content);
     }
     if (QA_DEBUG_PERFORMANCE) {
         ob_start();
         $qa_usage->output();
         $contents .= ob_get_contents();
         ob_end_clean();
     }
     qa_db_disconnect();
     exit($contents);
 }
开发者ID:stevenev,项目名称:q2a-caching,代码行数:39,代码来源:qa-caching-main.php

示例10: qa_base_db_connect

function qa_base_db_connect($failhandler = null)
{
    qa_db_connect($failhandler);
}
开发者ID:TheProjecter,项目名称:microprobe,代码行数:4,代码来源:qa-base.php

示例11: qa_db_pdo_connection

/**
 * Return the current connection to the Q2A database, connecting if necessary and $connect is true.
 */
function qa_db_pdo_connection($connect = true)
{
    global $qa_db_pdo_connection;
    if ($connect && is_null($qa_db_pdo_connection)) {
        $host = QA_PERSISTENT_CONN_DB ? 'p:' . QA_FINAL_MYSQL_HOSTNAME : QA_FINAL_MYSQL_HOSTNAME;
        $port = '';
        if (defined('QA_FINAL_MYSQL_PORT')) {
            $port = ";port=" . QA_FINAL_MYSQL_PORT;
        }
        $dbname = QA_FINAL_MYSQL_DATABASE;
        $username = QA_FINAL_MYSQL_USERNAME;
        $password = QA_FINAL_MYSQL_PASSWORD;
        $qa_db_pdo_connection = new PDO("mysql:host={$host};dbname={$dbname}{$port}", $username, $password, array(PDO::ATTR_TIMEOUT => 5, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
        qa_db_connect();
        if (is_null($qa_db_pdo_connection)) {
            qa_fatal_error('Failed to connect to database');
        }
    }
    return $qa_db_pdo_connection;
}
开发者ID:camelcasetechsd,项目名称:certigate,代码行数:23,代码来源:qa-external-users.php


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