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


PHP createDBConnection函数代码示例

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


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

示例1: migrate

 private function migrate($user, $rollback = false)
 {
     $class = config('tenants.user');
     try {
         if ($rollback) {
             createDBConnection($user);
             $class::rollback($user);
         } else {
             createDBConnection($user);
             $class::migrate($user);
             //Custom raw
             //DB::statement("ALTER TABLE GS_businesses ADD printInvoice INT UNSIGNED NOT NULL DEFAULT '0'");
         }
     } catch (\Exception $e) {
         $this->error('[Error] ' . $e->getMessage());
     }
 }
开发者ID:badchoice,项目名称:grog,代码行数:17,代码来源:TenantsMigrate.php

示例2: newTenant

 public static function newTenant($username, $password, $language = 'en', array $extraUserFields = [])
 {
     $username = preg_replace("/[^a-z0-9]+/", "", strtolower($username));
     if (static::doesUserExists($username)) {
         throw new \Exception("Username already exists");
     }
     $databaseName = config('tenants.DB_TENANTS_PREFIX') . $username;
     App::setLocale($language);
     try {
         DB::statement('create database ' . $databaseName . ';');
         createDBConnection($username);
         $newArray = ['username' => $username, 'password' => Hash::make($password), 'appPassword' => Hash::make($password), 'language' => $language];
         $user = static::create(array_merge($newArray, $extraUserFields));
         static::migrateAndSeed($username);
         return $user;
     } catch (\Exception $e) {
         DB::statement('drop database ' . $databaseName . ';');
         if ($user) {
             $user->forceDelete();
         }
         throw $e;
     }
 }
开发者ID:badchoice,项目名称:grog,代码行数:23,代码来源:TenantTrait.php

示例3: createDBConnection

<?php

include_once __DIR__ . "/login_check.php";
include_once __DIR__ . "/config.php";
include_once __DIR__ . "/../../src/db_common.php";
/**
 * プロジェクト検体サンプル一覧
 */
$db = createDBConnection();
// ---------------------
// parameters 取得
// ---------------------
$grp_id = \Sop\Session::getSiteData('grp_id');
$user_id = \Sop\Session::getSiteData('user_id');
$pj_id = array_key_exists('pj_id', $_REQUEST) ? $_REQUEST['pj_id'] : '';
$start = array_key_exists('start', $_REQUEST) ? intval($_REQUEST['start']) : 0;
$limit = array_key_exists('limit', $_REQUEST) ? intval($_REQUEST['limit']) : 25;
// ---------------------
// データ取得
// ---------------------
$sel_sql = getSQLBaseForPjSmplList();
$sel_sql .= " WHERE pj_smpl.pj_id = :pj_id AND v_pj.grp_id = :grp_id";
$params = array();
$params[':pj_id'] = $pj_id;
$params[':grp_id'] = $grp_id;
// --- 件数取得
$sql = "SELECT count(*) cnt FROM ({$sel_sql}) as tmp";
$stmt = $db->prepare($sql);
$stmt->execute($params);
$cnt = 0;
foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
开发者ID:Yusuke-KOMIYAMA,项目名称:sop,代码行数:31,代码来源:json_pjsmpl.php

示例4: session_start

<?php

require '/resources/php/generalFunctions.php';
require '/resources/php/profileFunctions.php';
if (session_id() == '' || !isset($_SESSION)) {
    // session isn't started
    session_start();
}
$mysqli = createDBConnection();
//db connection object
$history = getCompanyHistory($_SESSION['user_id']);
//employment history of user
$companies = getCompanyList($mysqli);
//company list for dropdown
$companyArray = array();
while ($row = $companies->fetch_assoc()) {
    $companyArray[] = $row;
}
$companyList = json_encode($companyArray);
$userInfo = getUserInfo($_SESSION['user_id']);
//user info
$userInfo = $userInfo->fetch_assoc();
$positionCount = getPostCount($mysqli, $_SESSION['user_id']);
$postScoreSQL = "SELECT IFNULL(TRUNCATE(AVG(`rating`), 2), '-') AS 'rating'\n                FROM\n                (\n                SELECT `post_id`\n                FROM `position_post`\n                WHERE `fk_user_id` = " . $_SESSION['user_id'] . "\n                ) A\n                LEFT JOIN `position_post_rating`\n                ON `A`.`post_id` = `position_post_rating`.`fk_position_post`";
$postScoreQuery = $mysqli->query($postScoreSQL)->fetch_assoc();
$postScore = $postScoreQuery['rating'];
$mysqli->close();
?>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
开发者ID:bryanbailey,项目名称:TEAM6_Jossip,代码行数:31,代码来源:profile.php


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