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


PHP R::selectDatabase方法代码示例

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


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

 public function select($group)
 {
     $this->host = $this->config[$group]['hostname'];
     $this->user = $this->config[$group]['username'];
     $this->pass = $this->config[$group]['password'];
     $this->dbname = $this->config[$group]['database'];
     R::selectDatabase($group);
 }
开发者ID:FaddliLWibowo,项目名称:MapIgniter,代码行数:8,代码来源:rb.php

示例3: loadDatabase

 public static function loadDatabase($dbFile)
 {
     $path = strpos($dbFile, DIRECTORY_SEPARATOR) === false ? Config::$dbPath . DIRECTORY_SEPARATOR . $dbFile : $dbFile;
     $dsn = 'sqlite:' . $path;
     $key = basename($path);
     R::addDatabase($key, $dsn, null, null, true);
     R::selectDatabase($key);
     R::exec('PRAGMA foreign_keys=ON');
     R::exec('PRAGMA temp_store=MEMORY');
 }
开发者ID:BrokenSilence,项目名称:malgraph4,代码行数:10,代码来源:Database.php

示例4: joomla

 public static function joomla($prefix, $facade = null)
 {
     $app = JFactory::getApplication();
     if ($app->getCfg('dbtype') == 'mysqli') {
         $type = 'mysql';
     } else {
         $type = $app->getCfg('dbtype');
     }
     if (is_null($facade)) {
         R::addDatabase('joomla', $type . ':' . 'host=' . $app->getCfg('host') . ';' . 'dbname=' . $app->getCfg('db'), $app->getCfg('user'), $app->getCfg('password'));
         R::selectDatabase('joomla');
         R::prefix($prefix);
     } else {
         $facade::addDatabase('joomla', $type . ':' . 'host=' . $app->getCfg('host') . ';' . 'dbname=' . $app->getCfg('db'), $app->getCfg('user'), $app->getCfg('password'));
         $facade::selectDatabase('joomla');
         $facade::prefix($prefix, $facade);
     }
 }
开发者ID:daviddeutsch,项目名称:redbean-joomla,代码行数:18,代码来源:RedBean_Joomla.php

示例5: activate_driver

function activate_driver($d)
{
    R::selectDatabase($d);
}
开发者ID:skullyframework,项目名称:skully,代码行数:4,代码来源:runtests.php

示例6: exit

    exit('Ldap bind failed');
}
$user_dn = 'cn=' . $user_name . ',ou=people,dc=gds-services,dc=com';
ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0);
$ldap_bd = ldap_bind($ldap_conn, $user_dn, $user_pass);
if (!$ldap_bd) {
    header('Content-type:text/json;charset=utf-8');
    echo json_encode(['result' => 'failed', 'error' => 'invalid user']);
    ldap_close($ldap_conn);
    die;
}
ldap_close($ldap_conn);
// Save
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);
try {
    $user_exists = R::find('wxpe_users', 'openid = :openid', [':openid' => $user_openid]);
    $user_exists = array_filter($user_exists);
    if (empty($user_exists)) {
        $user_new = R::getRedBean()->dispense('wxpe_users');
        $user_new->openid = $user_openid;
        $user_new->phone = '';
        $user_new->email = $user_name;
        $user_new->extra = $user_pass;
        $user_new_id = R::store($user_new);
    } else {
开发者ID:adexbn,项目名称:gds_wechat,代码行数:31,代码来源:user_bind_pe.php

示例7: __call

 public function __call($func, $args)
 {
     R::selectDatabase($this->key);
     $func = "R::{$func}";
     return call_user_func_array($func, $args);
 }
开发者ID:bobseven,项目名称:Slim-Blog,代码行数:6,代码来源:rb.php

示例8: RedBeanConnect

 /**
  * 
  * @param string $dbname
  * @param boolean $frozen
  * @return void
  */
 protected static function RedBeanConnect($dbname, $frozen = true)
 {
     require_once implode(DIRECTORY_SEPARATOR, [ROOT_DIR, 'Library', 'database', 'rb.php']);
     $dbConfig = static::$dbConfig;
     switch (strtoupper($dbConfig->type)) {
         case 'SQLITE':
             $dns = "sqlite:/tmp/{$dbname}.sqlite3";
             $dbConfig->user = $dbConfig->password = null;
             break;
         case 'MARIA':
             $dns = "mysql:host={$dbConfig->host};dbname={$dbname}";
             break;
         case 'POSTGRESQL':
             $dns = "pgsql:host={$dbConfig->host};dbname={$dbname}";
             break;
         case null:
         default:
             $dns = null;
             $dbConfig->user = $dbConfig->password = null;
     }
     if (isset(R::$toolboxes[$dbname])) {
         R::selectDatabase($dbname);
     } else {
         R::addDatabase($dbname, $dns, $dbConfig->user, $dbConfig->password, $frozen);
         R::selectDatabase($dbname);
     }
     R::setAutoResolve();
     R::fancyDebug(DEBUG);
 }
开发者ID:xandros15,项目名称:Saya-Bot,代码行数:35,代码来源:Module.php

示例9: json_encode

        $relate_6->yidong_code = $run_type . $run_time . '-' . $dc_id;
        $relate_6->zhanshileixing = 0;
        $relate_6->guanlianname = '客户用电较上月浮动最大Top5';
        $relate_6->yidongmiaoshu = json_encode($top5, JSON_UNESCAPED_UNICODE);
        $relate_6->guanlianzhi = $run_time;
        if (R::store($relate_6) <= 0) {
            exit('DB relate_6 insert failed \\n');
        }
    }
} catch (Exception $e) {
    exit('DB relate_6 insert failed \\n' . $e->getMessage());
}
R::close();
/* 写入运行日志 */
R::addDatabase('config', $GLOBALS['db_config_url'], $GLOBALS['db_config_user'], $GLOBALS['db_config_pass']);
R::selectDatabase('config');
if (!R::testConnection()) {
    exit('DB config connect failed \\n' . $e->getMessage());
}
R::freeze(TRUE);
try {
    $run_log = R::getRedBean()->dispense('sys_run_log');
    $run_log->alarm_type = $run_type;
    $run_log->last_run = $run_time;
    if (R::store($run_log) <= 0) {
        exit('DB config insert failed \\n');
    }
} catch (Exception $e) {
    exit('DB config insert failed \\n' . $e->getMessage());
}
R::close();
开发者ID:adexbn,项目名称:gds_alarm,代码行数:31,代码来源:pue_month.php

示例10: exit

R::selectDatabase('kayako');
if (!R::testConnection()) {
    exit('DB failed' . PHP_EOL);
}
R::freeze(true);
try {
    $user = R::getRow('     SELECT su.userid,' . '            su.fullname, ' . '            sm.email,' . '            su.phone,' . '            su.userorganizationid,' . '            so.organizationname ' . '       FROM kayako_fusion.swusers su' . ' INNER JOIN kayako_fusion.swuseremails sm' . '         ON su.userid = sm.linktypeid' . '        AND sm.linktype = 1' . ' INNER JOIN kayako_fusion.swuserorganizations so' . '         ON so.userorganizationid = su.userorganizationid' . '      WHERE email = :email', [':email' => $user_name]);
} catch (Exception $e) {
    header('Content-type:text/json;charset=utf-8');
    echo json_encode(['result' => 'failed', 'error' => 'db error kayako', 'details' => $e->getMessage()]);
    die;
}
R::close();
// Save frequent people
R::addDatabase('supportsr', $GLOBALS['db_supportsr_url'], $GLOBALS['db_supportsr_user'], $GLOBALS['db_supportsr_pass']);
R::selectDatabase('supportsr');
if (!R::testConnection()) {
    exit('DB failed' . PHP_EOL);
}
R::freeze(true);
try {
    R::begin();
    foreach ($people_array as $people) {
        $person_old = R::getCell(' SELECT id ' . '   FROM supportsr.esr_frequent_people ' . '  WHERE name = :name ' . '    AND paper_number = :p_number ', [':name' => $people->pname, ':p_number' => $people->pidval]);
        if (empty($person_old) || $person_old == "") {
            $person_new = R::getRedBean()->dispense('esr_frequent_people');
            $person_new->name = $people->pname;
            $person_new->paper_type = $people->ptype == '身份证' ? '身份证/Id card' : ($people->ptype == '台胞证' ? '台胞证/Efficiency certificate' : ($people->ptype == '护照' ? '护照/Passport' : ($people->ptype == '港澳通行证' ? '港澳通行证/Hong Kong-Macau passport' : ($people->ptype == '驾驶证' ? '驾驶证/Driving license' : ''))));
            $person_new->paper_number = $people->pidval;
            $person_new->comid = $user['organizationname'] . '|*|' . $user['userorganizationid'];
            $person_new_id = R::store($person_new);
开发者ID:adexbn,项目名称:gds_wechat,代码行数:31,代码来源:request_create_equip_in.php

示例11: 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

示例12: 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

示例13: foreach

R::selectDatabase("D1");
R::wipe('bottle');
foreach (R::dispense('bottle', 5) as $bottle) {
    R::store($bottle);
}
R::selectDatabase("D2");
R::wipe('bottle');
foreach (R::dispense('bottle', 3) as $bottle) {
    R::store($bottle);
}
R::selectDatabase("D1");
asrt(intval(R::getCell('select count(*) from bottle')), 5);
R::selectDatabase("D2");
asrt(intval(R::getCell('select count(*) from bottle')), 3);
asrt(count(R::findAndExport('bottle')), 3);
R::selectDatabase("D1");
asrt(count(R::findAndExport('bottle')), 5);
testpack("Facade Basics");
R::setup("sqlite:/tmp/teststore.txt");
//should work as well
pass();
R::exec("select 123");
pass();
unlink("/tmp/teststore.txt");
asrt(file_exists("/tmp/teststore.txt"), FALSE);
R::setup("sqlite:/tmp/teststore.txt");
asrt(R::$redbean instanceof RedBean_OODB, TRUE);
asrt(R::$toolbox instanceof RedBean_Toolbox, TRUE);
asrt(R::$adapter instanceof RedBean_Adapter, TRUE);
asrt(R::$writer instanceof RedBean_QueryWriter, TRUE);
$book = R::dispense("book");
开发者ID:ryjkov,项目名称:redbean,代码行数:31,代码来源:test.php

示例14: logresult

function logresult($userid, $text)
{
    R::selectDatabase('localdb');
    R::begin();
    $logtext = "";
    if (is_array($text)) {
        foreach ($text as $value) {
            $logtext .= $value . "; ";
        }
    } else {
        $logtext = $text;
    }
    $logtext = strip_tags($logtext);
    $sent = R::dispense('sent');
    $sent->number = $userid;
    $sent->text = $logtext;
    R::store($sent);
    R::commit();
    R::selectDatabase('default');
}
开发者ID:arshadalisoomro,项目名称:OpenSourceBikeShare,代码行数:20,代码来源:common.php

示例15: PDO

require 'api_rb.php';
require 'api_db.php';
// Query get name, title, skill
try {
    $db = new PDO($GLOBALS['db_remedy_url'], $GLOBALS['db_remedy_user'], $GLOBALS['db_remedy_pass'], array(PDO::ATTR_PERSISTENT => true));
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $sql = $db->prepare(' SELECT Distinct remedy_login_id ' . '   FROM CTM_PeopleUserSupportGroupFunc ' . '  WHERE Functional_Role = \'Work Order Assignee\' ' . '    AND Organization = \'数据中心服务部\' ', [PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY]);
    $sql->execute();
    $staff_dcs_accounts = $sql->fetchAll(PDO::FETCH_ASSOC);
    $staff_dcs_account_vals = array_column($staff_dcs_accounts, 'remedy_login_id');
    $sql = null;
} catch (PDOException $e) {
    exit('DB remedy select failed \\n' . $e->getMessage());
}
R::addDatabase('portal', $GLOBALS['db_portal_url'], $GLOBALS['db_portal_user'], $GLOBALS['db_portal_pass']);
R::selectDatabase('portal');
if (!R::testConnection()) {
    exit('DB failed' . PHP_EOL);
}
R::freeze(true);
try {
    if (!empty($staff_dcs_account_vals)) {
        $staff_dcss = R::getAll('SELECT name        AS fullname, ' . '       email       AS email, ' . '       cell_phone  AS mobilenumber' . '  FROM gdsportal.auth_user ' . ' WHERE username IN (' . R::genSlots($staff_dcs_account_vals) . ')', $staff_dcs_account_vals);
    }
} catch (Exception $e) {
    header('Content-type:text/json;charset=utf-8');
    echo json_encode(['result' => 'failed', 'error' => 'db error portal', 'details' => $e->getMessage()]);
    die;
}
R::close();
// Return
开发者ID:adexbn,项目名称:gds_wechat,代码行数:31,代码来源:staff_dcs.php


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