本文整理汇总了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();
}
示例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);
}
示例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');
}
示例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);
}
}
示例5: activate_driver
function activate_driver($d)
{
R::selectDatabase($d);
}
示例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 {
示例7: __call
public function __call($func, $args)
{
R::selectDatabase($this->key);
$func = "R::{$func}";
return call_user_func_array($func, $args);
}
示例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);
}
示例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();
示例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);
示例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);
示例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;
}
示例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");
示例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');
}
示例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