コード例 #1
0
ファイル: model.php プロジェクト: YDziashkevich/dbParadox
 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
0
ファイル: Model.php プロジェクト: GLenotre/codeup.dev
 /**
  * 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
0
ファイル: Model.php プロジェクト: zgulde/contacts-manager
 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
0
 /**
  * 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
0
 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
0
ファイル: Model.php プロジェクト: dklunariley/codeup.dev
 /**
  * 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=localhost;dbname=codeup_test_db', 'codeup_test_user', 'password');
         self::$dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     }
 }
コード例 #7
0
 protected static function dbConnect()
 {
     if (!self::$dbc) {
         require __DIR__ . '/../database/db_connect.php';
         self::$dbc = $dbc;
     }
 }
コード例 #8
0
 private static function dbConnect()
 {
     if (!self::$dbc) {
         require 'db_connect.php';
         self::$dbc = $dbc;
     }
 }
コード例 #9
0
ファイル: Basemodel.php プロジェクト: ztr-adlister/adlister
 public static function dbConnect()
 {
     if (!self::$dbc) {
         require '../db/db_connect.php';
         self::$dbc = $dbc;
     }
 }
コード例 #10
0
ファイル: BaseModel.php プロジェクト: Radlister/radlister.dev
 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);
     }
 }
コード例 #11
0
ファイル: BaseModel.php プロジェクト: sakrog/listmorecoals
 protected static function dbConnect()
 {
     if (!self::$dbc) {
         // @TODO: Connect to database
         require "../database/dbconnect.php";
         self::$dbc = $dbc;
     }
 }
コード例 #12
0
 private static function dbConnect()
 {
     if (!self::$dbc) {
         require_once 'Model_login.php';
         require_once 'dbconnect.php';
         self::$dbc = $dbc;
     }
 }
コード例 #13
0
ファイル: Model.php プロジェクト: Penthious/Codeup.dev
 /**
  * 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);
     }
 }
コード例 #14
0
 private static function dbConnect()
 {
     if (!self::$dbc) {
         // @TODO: Connect to database
         require "db_connect.php";
         self::$dbc = $dbc;
     }
 }
コード例 #15
0
ファイル: Model.php プロジェクト: stanholzendorf/codeup.dev
 /**
  * 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
     }
 }
コード例 #16
0
ファイル: basemodel.php プロジェクト: Gistslist/DisGistsList
 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);
     }
 }
コード例 #17
0
 /**
  * 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 = "******";
         $password = "******";
         self::$dbc = new PDO("mysql:host={$servername};dbname={$dbname}", $username, $password);
         self::$dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     }
 }
コード例 #18
0
ファイル: Model1.php プロジェクト: stanholzendorf/codeup.dev
 /**
  * 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) {
         // Connect to database
         $dbc = new PDO('mysql:host=127.0.0.1;dbname=users_db', 'admin_user', 'x');
         self::$dbc = $dbc;
         self::$table = 'users';
         // Throw exception on PDO error
         self::$dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     }
 }
コード例 #19
0
 protected static function dbConnect()
 {
     /* if not already connected, go to next line & connect; singleton pattern - only want one instance of db connection
        if changed to static would allow override which we don't want
        could paste contents of configUser_db.php here instead of requiring once at top*/
     if (!self::$dbc) {
         /*    @TODO: Connect to database: user_db; name codeup; password codeup*/
         self::$dbc = new PDO('mysql:host=' . $_ENV['DB_HOST'] . ';dbname=' . $_ENV['DB_NAME'], $_ENV['DB_USER'], $_ENV['DB_PASS']);
         // Make sure that instance will use exceptions rather than failing silently.
         self::$dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     }
 }
コード例 #20
0
 private static function dbConnect()
 {
     if (!self::$dbc) {
         self::$dbc = (require 'db_connect.php');
     }
 }
コード例 #21
0
 protected static function dbConnect()
 {
     if (!self::$dbc) {
         self::$dbc = (require '../database/db.connect.php');
     }
 }