本文整理汇总了PHP中Model::dbc方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::dbc方法的具体用法?PHP Model::dbc怎么用?PHP Model::dbc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model
的用法示例。
在下文中一共展示了Model::dbc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDbc
public static function getDbc()
{
if (!self::$dbc) {
self::$dbc = new PDO("mysql: host=" . APP_DB_HOST . "; dbname=" . APP_DB_NAME, APP_DB_USER, APP_DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
}
return self::$dbc;
}
示例2: dbConnect
/**
* Connect to the DB
*
* This method should be called at the beginning of any function that needs to communicate with the database
*/
protected static function dbConnect()
{
if (!self::$dbc) {
$dbc = new PDO('mysql:host=127.0.0.1;dbname=codeup_test_db', 'vagrant', 'vagrant');
self::$dbc = $dbc;
}
}
示例3: dbConnect
private static function dbConnect()
{
if (!self::$dbc) {
self::$dbc = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS);
self::$dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
}
示例4: dbConnect
/**
* Connect to the DB
*
* This method should be called at the beginning of any function that needs to communicate with the database
*/
protected static function dbConnect()
{
if (!self::$dbc) {
self::$dbc = new PDO('mysql:host=127.0.0.1;dbname=codeup_test_db', 'codeup', 'codeup');
self::$dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
}
示例5: dbConnect
protected static function dbConnect()
{
if (!self::$dbc) {
self::$dbc = new PDO('mysql:host=' . $_ENV['DB_HOST'] . ';dbname=' . $_ENV['DB_NAME'], $_ENV['DB_USER'], $_ENV['DB_PASS']);
self::$dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
}
示例6: dbConnect
protected static function dbConnect()
{
if (!self::$dbc) {
require __DIR__ . '/../database/db_connect.php';
self::$dbc = $dbc;
}
}
示例7: dbConnect
private static function dbConnect()
{
if (!self::$dbc) {
require 'db_connect.php';
self::$dbc = $dbc;
}
}
示例8: dbConnect
public static function dbConnect()
{
if (!self::$dbc) {
require '../db/db_connect.php';
self::$dbc = $dbc;
}
}
示例9: dbConnect
protected static function dbConnect()
{
if (!self::$dbc) {
self::$dbc = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS);
// Tell PDO to throw exceptions on error
self::$dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
}
示例10: dbConnect
protected static function dbConnect()
{
if (!self::$dbc) {
// @TODO: Connect to database
require "../database/dbconnect.php";
self::$dbc = $dbc;
}
}
示例11: dbConnect
private static function dbConnect()
{
if (!self::$dbc) {
require_once 'Model_login.php';
require_once 'dbconnect.php';
self::$dbc = $dbc;
}
}
示例12: dbConnect
/**
* Connect to the DB
*
* This method should be called at the beginning of any function that needs to communicate with the database
*/
protected static function dbConnect()
{
if (!self::$dbc) {
// @TODO: Connect to database
self::$dbc = new PDO('mysql:host=' . DB_host . ';dbname=' . DB_name, DB_user, DB_password);
self::$dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
}
示例13: dbConnect
/**
* Connect to the DB
*
* This method should be called at the beginning of any function that needs to communicate with the database
*/
protected static function dbConnect()
{
if (!self::$dbc) {
$dbc = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, PASSWORD);
self::$dbc = $dbc;
// @TODO: Connect to database
}
}
示例14: dbConnect
private static function dbConnect()
{
// If the static property $dbc has not been set, then assign it.
if (!self::$dbc) {
self::$dbc = new PDO('mysql:host=' . DB_HOST . ';
dbname=' . DB_NAME, DB_USER, DB_PASS);
// Tell PDO to throw exceptions on error
self::$dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
}
示例15: dbConnect
/**
* Connect to the DB
*
* This method should be called at the beginning of any function that needs to communicate with the database
*/
protected static function dbConnect()
{
if (!self::$dbc) {
$servername = "localhost";
$dbname = "parks_db";
$username = "vagrant";
$password = "vagrant";
self::$dbc = new PDO("mysql:host={$servername};dbname={$dbname}", $username, $password);
self::$dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
}