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


PHP R::testConnection方法代码示例

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


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

示例1: _log_focus

function _log_focus($openid, $operation, $user_info = NULL)
{
    R::addDatabase('wechat_csc', $GLOBALS['db_wechat_csc_url'], $GLOBALS['db_wechat_csc_user'], $GLOBALS['db_wechat_csc_pass']);
    R::selectDatabase('wechat_csc');
    if (!R::testConnection()) {
        exit('DB failed' . PHP_EOL);
    }
    R::freeze(true);
    try {
        $user = R::getRedBean()->dispense('wxcsc_focus');
        $user->openid = $openid;
        $user->operation = $operation;
        if ($operation == 'focus' && $user_info != NULL) {
            $user->nickname = $user_info['nickname'];
            $user->sex = $user_info['sex'];
            $user->language = $user_info['language'];
            $user->city = $user_info['city'];
            $user->province = $user_info['province'];
            $user->country = $user_info['country'];
        }
        $user_id = R::store($user);
    } catch (Exception $e) {
        header('Content-type:text/json;charset=utf-8');
        echo json_encode(['result' => 'failed', 'error' => 'db error wechat', 'details' => $e->getMessage()]);
        die;
    }
    R::close();
}
开发者ID:adexbn,项目名称:gds_wechat,代码行数:28,代码来源:api_csc.php

示例2: __construct

 public function __construct()
 {
     require_once 'libs/rb.php';
     if (!R::testConnection()) {
         R::setup('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS);
     }
 }
开发者ID:reminchev,项目名称:SoftUni-Projects,代码行数:7,代码来源:BaseModel.php

示例3: session_start

session_start();
$callback = isset($_REQUEST['bcb']) ? $_REQUEST['bcb'] : '';
$openid = isset($_SESSION['openid']) ? $_SESSION['openid'] : (isset($_REQUEST['openid']) ? $_REQUEST['openid'] : '');
_log(json_encode(['openid' => $openid, 'callback' => $callback]));
// Check
if ($openid == '') {
    header('Location: ' . $csc_url_base . '/static/html/user_not_focus_csc.html?bcb=' . $callback . '&rand=' . rand() . '#mp.weixin.qq.com');
    die;
}
if (!isset($_SESSION['openid'])) {
    $_SESSION['openid'] = $openid;
}
// Query
R::addDatabase('wechat_csc', $GLOBALS['db_wechat_csc_url'], $GLOBALS['db_wechat_csc_user'], $GLOBALS['db_wechat_csc_pass']);
R::selectDatabase('wechat_csc');
if (!R::testConnection()) {
    exit('DB failed' . PHP_EOL);
}
R::freeze(true);
try {
    $user_email = R::getCell('SELECT wu.email' . '  FROM wxcsc_users wu' . ' WHERE wu.openid = :openid' . ' LIMIT 1', [':openid' => $openid]);
} catch (Exception $e) {
    header('Location: ' . $csc_url_base . '/static/html/error_message.html?msg=' . urlencode($e->getMesage()) . '&rand=' . rand() . '#mp.weixin.qq.com');
    die;
}
R::close();
_log(json_encode(['openid' => $openid, 'user_email' => $user_email]));
// Error return
if ($user_email == '') {
    if ($callback == 'user_bind_check_csc') {
        header('Location: ' . $csc_url_base . '/static/html/user_bind_1_csc.html?rand=' . rand() . '#mp.weixin.qq.com');
开发者ID:adexbn,项目名称:gds_wechat,代码行数:31,代码来源:user_isbind_csc.php

示例4: init

function init()
{
    // Setup our RedBean environment.
    R::setup('mysql:host=' . DATABASE_HOST . '; dbname=' . DATABASE_NAME, DATABASE_USERNAME, DATABASE_PASSWORD, REDBEAN_FREEZE_ENABLED);
    // Attempt to connect to the configured Database
    if (!R::testConnection()) {
        throw new Exception('Couldn\'t connect to database. Please check backend configuration.');
    }
    // Enable debug mode
    R::debug(REDBEAN_DEBUG_ENABLED);
    // Use camelCase for bean export
    R::useExportCase('camel');
}
开发者ID:Raffprta,项目名称:raffprtaeu,代码行数:13,代码来源:index.php

示例5: testpack

<?php

/**
 * Pretest
 *
 * These tests will run before the configuration takes place
 * in the unit test suite (mostly error handling tests).
 *
 * @file    RedUNIT/Pretest.php
 * @desc    Test scripts that run before configuration
 * @author  Gabor de Mooij and the RedBeanPHP Community
 * @license New BSD/GPLv2
 *
 * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
 * This source file is subject to the New BSD/GPLv2 License that is bundled
 * with this source code in the file license.txt.
 */
testpack('Running pre-tests. (before config).');
try {
    R::debug(TRUE);
    fail();
} catch (Exception $e) {
    pass();
}
asrt(R::testConnection(), FALSE);
R::addDatabase('broken', 'mysql:host=nowhere', 'defunct', 'void');
R::selectDatabase('broken');
asrt(R::testConnection(), FALSE);
开发者ID:diego-vieira,项目名称:redbean,代码行数:28,代码来源:Pretest.php

示例6: get_pe_wechat

function get_pe_wechat($staff_email)
{
    // Wechat PE
    //R::addDatabase('wechat_pe', $GLOBALS['db_wechat_pe_url'], $GLOBALS['db_wechat_pe_user'], $GLOBALS['db_wechat_pe_pass']);
    R::selectDatabase('wechat_pe');
    if (!R::testConnection()) {
        exit('DB failed' . PHP_EOL);
    }
    R::freeze(true);
    if (TEST_SEND) {
        $staff_email = DEBUG_EMAIL;
    }
    $email_prefix = explode("@", $staff_email);
    try {
        $openids = R::getAll(' SELECT openid ' . '   FROM wechat_pe.wxpe_users ' . '  WHERE email = :email_1 ' . '     OR email = :email_2 ', [':email_1' => $email_prefix[0], ':email_2' => ucfirst($email_prefix[0])]);
    } catch (Exception $e) {
        die(json_encode(['result' => 'failed', 'error' => 'db error wechat_pe', 'details' => $e->getMessage()]));
    }
    R::close();
    return $openids;
}
开发者ID:adexbn,项目名称:gds_wechat,代码行数:21,代码来源:notification_send.php


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