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


PHP Model::db方法代码示例

本文整理汇总了PHP中Model::db方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::db方法的具体用法?PHP Model::db怎么用?PHP Model::db使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model的用法示例。


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

示例1: StartApp

		public static function StartApp()
		{
			ob_start('ob_gzhandler');
			session_start();
			
			// Defines
			define('BASEURL', substr((empty($_SERVER['HTTPS']) ? 'http://' : 'https://' ) . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'],0,-10));
			define('BASEPATH', substr($_SERVER['SCRIPT_FILENAME'],0,-10));
			
			// Helper Boot Loader
			require(BASEPATH.'/core/bootloader.php');
			
			// Initialize Helpers
			BootLoader::loadHelpers();
			Registry::getInstance();
			
			// Handle Errors
			Registry::setDebugMode(true);
			set_error_handler('Template::handleError');
			set_exception_handler('Template::handleException');
	
			// Initialize Database
			Model::$db = DBO::getInstance('sqlite:example.sqldb');
			
			// Init Autoloads
			spl_autoload_register('Autoload::controllers');
			spl_autoload_register('Autoload::models');
			
			// Determine Controllers and Methods
			Routes::getRoute();
			
			// Run Application
			Routes::run();
		}
开发者ID:nickbarth,项目名称:PHP-Tofu,代码行数:34,代码来源:index.php

示例2:

 /**
  * 构造函数
  *
  */
 function __construct()
 {
     // 获取数据库操作对象
     if (self::$db == null) {
         self::$db = base::get_instance()->db;
     }
     $this->cache =& $GLOBALS['memcached'];
 }
开发者ID:noikiy,项目名称:webgame,代码行数:12,代码来源:Model.php

示例3: nuevaDb

 protected static function nuevaDb()
 {
     include_once SYS_PATH . 'DataBase.php';
     if (!isset(Model::$db)) {
         Model::$db = new DataBase();
     }
     return Model::$db;
 }
开发者ID:RamiroAlvaro,项目名称:ProyectoDeSoftware,代码行数:8,代码来源:Model.php

示例4: __construct

 public function __construct($data = null, $rawData = false)
 {
     self::$services = ServiceContainer::getInstance();
     self::$db = self::$services->get('db');
     $this->initialize();
     if ($data) {
         $rawData ? $this->setRawData($data) : $this->setData($data);
     }
 }
开发者ID:migumuno,项目名称:obesity,代码行数:9,代码来源:Model.php

示例5: setDataSourse

 /**
  * Set a PDO connection to be reused
  */
 private static function setDataSourse()
 {
     try {
         $datasoursename = DBConfig::TYPE . ':host=' . DBConfig::HOST . ';dbname=' . DBConfig::NAME;
         $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING);
         self::$db = new PDO($datasoursename, DBConfig::USER, DBConfig::PASS, $options);
     } catch (PDOException $e) {
         exit('Database connection could not be established.');
     }
 }
开发者ID:kmiksi,项目名称:frameworkless,代码行数:13,代码来源:Model.php

示例6: __construct

 /**
  * Creates a PDO connection to MySQL
  *
  * @return boolean  Returns TRUE on success (dies on failure)
  */
 public function __construct()
 {
     $dsn = 'mysql:dbname=' . DB_NAME . ';host=' . DB_HOST;
     try {
         self::$db = new PDO($dsn, DB_USER, DB_PASS);
     } catch (PDOExeption $e) {
         die("Couldn't connect to the database.");
     }
     return TRUE;
 }
开发者ID:kai-cn,项目名称:bookcode-realtimewebapps,代码行数:15,代码来源:class.model.inc.php

示例7: _construct

 /**
  * Creates a PDO connection to your datebase.
  *
  * @return boolean
  */
 public function _construct()
 {
     $dsn = 'mysql:dbname' . DB_NAME . ';host=' . DB_HOST;
     try {
         self::$db = new PDO($dsn, DB_USER, DB_PASS);
     } catch (PDOException $e) {
         $echoError = new Error($e);
         exit;
     }
     return TRUE;
 }
开发者ID:Alien-2001,项目名称:PlutoFramework,代码行数:16,代码来源:class.model.php

示例8: getBd

 /**
  * Renvoie un objet de connexion à la BD en initialisant la connexion au besoin
  * 
  * @return PDO L'objet PDO de connexion à la BDD
  */
 private static function getBd()
 {
     if (self::$db == null) {
         // Récupération des paramètres de configuration BD
         $connection = Configuration::get("connection");
         $login = Configuration::get("login");
         $password = Configuration::get("password");
         // Création de la connexion
         self::$db = new PDO($connection, $login, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
     }
     return self::$db;
 }
开发者ID:akachbat,项目名称:MVC-Framework,代码行数:17,代码来源:model.php

示例9: getDb

 /**
  * This function is used to create a connexion to the database with PDO
  * @return PDO Object
  */
 private function getDb()
 {
     if (self::$db === null) {
         //recovery of configuration parameters to connect to the database
         $dsn = Configuration::get("dsn");
         $login = Configuration::get("login");
         $password = Configuration::get("password");
         //Creation of the connexion
         self::$db = new PDO($dsn, $login, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
     }
     return self::$db;
 }
开发者ID:gcaggia,项目名称:blog_MVC,代码行数:16,代码来源:model.class.php

示例10: getInstance

 public static function getInstance()
 {
     if (!isset(self::$db)) {
         try {
             self::$db = new \PDO('mysql:host=' . 'localhost' . ';dbname=' . 'teste', 'root', '1234');
             self::$db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
             self::$db->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_OBJ);
         } catch (PDOException $e) {
             die("Erro na Conexão: " . $e->getMessage());
         }
     }
     return self::$db;
 }
开发者ID:GabriellLima,项目名称:VeryPHP,代码行数:13,代码来源:Model.php

示例11: init

 static function init()
 {
     Model::db();
     Model::check_login();
     foreach (glob(APP_PATH . SL . 'actionHelpers/*.php') as $file) {
         /** @noinspection PhpIncludeInspection */
         include_once $file;
     }
     global $titlePage;
     global $config;
     $titlePage = $config['settings']['title'];
     Route::launch();
 }
开发者ID:BostonLee,项目名称:EaT-CMS,代码行数:13,代码来源:bootstrap.php

示例12: __construct

 public function __construct(array $_data = array())
 {
     if (!isset(self::$db)) {
         self::$db = Core::getDb();
     }
     if (!isset(self::$request)) {
         self::$request = Core::$request;
     }
     if (!isset(self::$profile)) {
         self::$profile = Auth::$profile;
         self::$uid = self::$profile->user_id;
     }
     if (isset($_data)) {
         $this->_data = $_data;
     }
 }
开发者ID:tiger154,项目名称:prototype,代码行数:16,代码来源:Model.php

示例13: __construct

 /**
  *构造函数
  *
  *完成数据库的链接
  */
 public function __construct()
 {
     //打开数据库
     $dns = 'mysql:host=' . DB_HOST . ';port=' . DB_PORT . ';dbname=' . DB_NAME;
     try {
         if (!isset(self::$db)) {
             //实例化PDO
             self::$db = new PDO($dns, DB_USER, DB_PASS);
             //开启异常处理模式
             self::$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
             //设置字符集
             self::$db->query('set names ' . DB_CHARSET);
         }
     } catch (PDOException $e) {
         die('无法打开数据库');
     }
 }
开发者ID:huolong1992,项目名称:baixiu,代码行数:22,代码来源:Model.class.php

示例14: __construct

 /**
  * 自动初始化
  * @param string $name  表名
  * @param string $prefix 前缀
  * @param string $connect 连接数据库的类型
  * @param string $alias 別名
  * @author wave
  */
 public function __construct($name = null, $prefix = null, $connect = null, $alias = null)
 {
     $this->_initialize();
     $this->prefix = $prefix;
     $this->name = $this->prefix . $name;
     $this->alias = $alias;
     $this->connect = $connect;
     if (empty(self::$db)) {
         //防止多次加載
         load('config.php', APP_PATH . DS . DATABASE);
         //数据库配置文件
         load('db.class.php', ROOT_PATH);
         //加载连接数据库类
         if (!empty($this->connect)) {
             self::$db = !empty($this->connect) ? self::link($this->connect) : 1;
             //进行初始化数据
         } else {
             self::$db = isset(config::$default) ? self::link(config::$default) : 1;
         }
     }
 }
开发者ID:DenonHuang,项目名称:xbphp,代码行数:29,代码来源:Model.php

示例15: connect

 public static function connect($server = "development")
 {
     $dbYaml = DB::getParse();
     self::$db = DB::connect($dbYaml[$server]['host'], $dbYaml[$server]['username'], $dbYaml[$server]['password'], $dbYaml[$server]['database']);
 }
开发者ID:rafaels88,项目名称:Kis-Framework,代码行数:5,代码来源:Model.class.php


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