本文整理汇总了PHP中R::close方法的典型用法代码示例。如果您正苦于以下问题:PHP R::close方法的具体用法?PHP R::close怎么用?PHP R::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类R
的用法示例。
在下文中一共展示了R::close方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: tearDown
function tearDown()
{
// Must use nuke() to clear caches etc.
R::nuke();
R::close();
$this->bbs = NULL;
system("rm -rf " . self::DATA);
}
示例3: testClose
/**
* Test closing database connection.
*
* @return void
*/
public function testClose()
{
asrt(R::$adapter->getDatabase()->isConnected(), TRUE);
R::close();
asrt(R::$adapter->getDatabase()->isConnected(), FALSE);
// Can we create a database using empty setup?
R::setup();
$id = R::store(R::dispense('bean'));
asrt($id > 0, TRUE);
// Test freeze via kickstart in setup
$toolbox = RedBean_Setup::kickstart('sqlite:/tmp/bla.txt', NULL, NULL, TRUE);
asrt($toolbox->getRedBean()->isFrozen(), TRUE);
// Test Oracle setup
$toolbox = RedBean_Setup::kickstart('oracle:test-value', 'test', 'test', FALSE);
asrt($toolbox instanceof RedBean_ToolBox, TRUE);
}
示例4: exit
$_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');
die;
} else {
if (in_array($callback, ['extra_news', 'extra_expert', 'dc_guide', 'extra_contact'])) {
header('Location: ' . $csc_url_base . '/static/html/' . $callback . '.html?rand=' . rand() . '#mp.weixin.qq.com');
die;
} else {
if (in_array($callback, ['extra_neighbour', 'extra_docs', 'user_dcs', 'user_tasks'])) {
header('Location: ' . $csc_url_base . '/static/html/' . $callback . '.html?rand=' . rand() . '#mp.weixin.qq.com');
die;
} else {
示例5: __destruct
function __destruct()
{
R::close();
}
示例6: shutdown
/**
* Shutdown function - this is used to catch certain errors that are not otherwise trapped and
* generate a clean screen as well as an error report to the developers.
*
* It also closes the RedBean connection
*/
public function shutdown()
{
if ($error = error_get_last()) {
# are we terminating with an error?
if (isset($error['type']) && ($error['type'] == E_ERROR || $error['type'] == E_PARSE || $error['type'] == E_COMPILE_ERROR)) {
# tell the developers about this
$this->telladmin($error['message'], $error['type'], $error['file'], $error['line']);
$this->make500();
} else {
echo '<div>There has been a system error</div>';
}
}
R::close();
# close RedBean connection
}
示例7: shortIt
private function shortIt($url, $md5)
{
if (!self::API_SHORT) {
return $url;
}
parent::RedBeanConnect('short');
if ($fetch = @R::findOne('short_url', '`title` = ?', [$md5])) {
return self::API_SHORT . $fetch->keyword;
}
$timestamp = date('Y-m-d H:i:s');
do {
$uniq = '';
$base = strtolower(hash('sha256', uniqid()));
while (strlen($uniq) < 8) {
$uniq .= substr($base, (int) -(strlen($base) / (1 + strlen($uniq))), 1);
}
} while (@R::findOne('short_url', '`keyword` = ?', [$uniq]));
$sql = 'INSERT INTO `short`.`short_url` ';
$sql .= "(`keyword`, `url`, `title`, `timestamp`, `ip`, `clicks`) ";
$sql .= "VALUES ('{$uniq}', '{$url}', '{$md5}', '{$timestamp}', '";
$sql .= getHostByName(getHostName()) . "', '0')";
R::exec($sql);
R::close();
return 'http://exsubs.anidb.pl/short/' . $uniq;
}
示例8: __destruct
public function __destruct()
{
$this->connection = null;
R::close();
}
示例9: _closeDBConnection
protected function _closeDBConnection()
{
R::close();
}
示例10: 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;
}
示例11: endTestSuite
public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
{
\R::nuke();
\R::close();
}
示例12: __destruct
public function __destruct()
{
self::$dbh = null;
R::close();
}
示例13: disconnect
public static function disconnect()
{
R::close();
}
示例14: createTable
private function createTable()
{
parent::RedBeanConnect(self::DB_NAME);
$sql = 'CREATE TABLE IF NOT EXISTS `' . self::TB_NAME . '`(';
$sql .= '`id` int(10) NOT NULL AUTO_INCREMENT,';
$sql .= '`name` varchar(25),';
$sql .= '`orginal` varchar(45) NOT NULL,';
$sql .= '`icon` varchar(100) NOT NULL,';
$sql .= '`link` varchar(100) NOT NULL,';
$sql .= '`linkgc` varchar(100) NOT NULL,';
$sql .= 'PRIMARY KEY (`id`)';
$sql .= ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;';
$sql = trim($sql);
R::exec($sql);
R::close();
}