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


PHP MySQLi::__construct方法代码示例

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


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

示例1: __construct

 /**
  * Database constructor (die on error).
  *
  * {@inheritdoc}
  */
 public function __construct($host = null, $username = null, $passwd = null, $dbName = null, $port = null, $socket = null)
 {
     parent::__construct($host, $username, $passwd, $dbName, $port, $socket);
     if (@(!$this->ping())) {
         die(PHP_EOL . 'ERROR: Could not connect to the mysql server using the supplied information.' . PHP_EOL);
     }
 }
开发者ID:DaazKu,项目名称:phpScriptingUtils,代码行数:12,代码来源:Database.php

示例2: __construct

 public function __construct()
 {
     // inhibit subclassing and instantiation from outside
     require_once 'pwd.php';
     // read account data (including password)
     // initialize the transient associative array
     $this->modelTransient = array();
     // initialize new or open existing session
     session_name($config['session']);
     session_start();
     // connect to database
     try {
         parent::__construct($config['host'], $config['user'], $config['pwd'], "ewa");
         // check connection
         if (mysqli_connect_error()) {
             // $this is invalid in case of error
             throw new Exception("Keine Verbindung zur Datenbank: " . mysqli_connect_error());
         }
     } catch (Exception $e) {
         // do not show the password in an error message
         throw new Exception(str_replace($config['pwd'], "xxx", $e->getMessage()));
     }
     // define character encoding for connection to database
     if (!$this->set_charset(self::charsetDB)) {
         throw new Exception("Fehler beim Laden des Zeichensatzes " . self::charsetDB . ": " . $this->error);
     }
 }
开发者ID:alican,项目名称:HalloPizza,代码行数:27,代码来源:ModelCore.php

示例3:

 function __construct()
 {
     self::$host = Config::get('db_host');
     self::$db = Config::get('db_name');
     self::$user = Config::get('db_user');
     self::$password = Config::get('db_pass');
     parent::__construct(self::$host, self::$user, self::$password, self::$db);
 }
开发者ID:runderwood,项目名称:redberry,代码行数:8,代码来源:class.db.php

示例4: __construct

 public function __construct($host, $username, $passwd, $dbname = "", $port, $socket)
 {
     $host = !isset($host) ? ini_get("mysqli.default_host") : $host;
     $username = !isset($username) ? ini_get("mysqli.default_user") : $username;
     $passwd = !isset($passwd) ? ini_get("mysqli.default_pw") : $passwd;
     $port = !isset($port) ? ini_get("mysqli.default_port") : $port;
     $socket = !isset($socket) ? ini_get("mysqli.default_socket") : $socket;
     parent::__construct($host, $username, $passwd, $dbname, $port, $socket);
     $this->query("SET SESSION sql_mode = ''");
 }
开发者ID:bluethrust,项目名称:clanscriptsv4,代码行数:10,代码来源:btmysql.php

示例5: __construct

 public function __construct()
 {
     require '/home/sites/aaa.to' . '/instagram_dbaccount.php';
     $dbhost = $CONF['dbhost'];
     $dbuser = $CONF['dbuser'];
     $dbpass = $CONF['dbpass'];
     $dbname = $CONF['dbname'];
     $dbport = $CONF['dbport'];
     parent::__construct($dbhost, $dbuser, $dbpass, $dbname, $dbport);
 }
开发者ID:ngsw,项目名称:aaa.to_instagram,代码行数:10,代码来源:instagrammysqli.php

示例6: __construct

 public function __construct($host = "", $username = "", $passwd = "", $dbname = "")
 {
     $this->host = $host ? $host : ini_get("mysql.default_host");
     $this->username = $username ? $username : ini_get("mysql.default_user");
     $this->passwd = $passwd ? $passwd : ini_get("mysql.default_password");
     $this->dbname = $dbname ? $dbname : "hb";
     parent::__construct($this->host, $this->username, $this->passwd, $this->dbname);
     if ($this->connect_errno) {
         die('Connect Error (' . $this->connect_errno . ') ' . $this->connect_error);
     }
 }
开发者ID:OpenBibleSearch,项目名称:morphhb,代码行数:11,代码来源:DBConnect.php

示例7: __construct

 /**
  * Construct from optional connection data
  *
  * If connection information is not provided, it will be read from the
  * corresponding ini options.
  *
  * @param string $host
  * @param string $username
  * @param string $passwd
  * @param string $dbname
  * @param string $port
  * @param string $socket
  * @return void
  */
 public function __construct($host = null, $username = null, $passwd = null, $dbname = null, $port = null, $socket = null)
 {
     $host = $host ?: ini_get('mysqli.default_host');
     $username = $username ?: ini_get('mysqli.default_user');
     $passwd = $passwd ?: ini_get('mysqli.default_pw');
     $dbname = $dbname ?: '';
     $port = $port ?: ini_get('mysqli.default_port');
     $socket = $socket ?: ini_get('mysqli.default_socket');
     @parent::__construct($host, $username, $passwd, $dbname, $port, $socket);
     if ($this->connect_errno) {
         throw new \RuntimeException("Could not connect to database: " . $this->connect_error);
     }
     \mysqli_report(\MYSQLI_REPORT_STRICT);
     $this->set_charset("utf8");
 }
开发者ID:JanPietrzyk,项目名称:review,代码行数:29,代码来源:MySQLi.php

示例8: __construct

	public function __construct($settings = false) {
		if(is_array($settings)) {
			foreach(array('host', 'username', 'password', 'dbname', 'charset', 'file_log', 'live_log', 'keep_log') as $foo)
				if(isset($settings[$foo])) $this->$foo = $settings[$foo];
		}
		parent::__construct($this->host, $this->username, $this->password, $this->dbname);
		if($this->charset) $this->set_charset($this->charset);
			if(php_sapi_name() == 'cli') { // running in console
				$this->colors = array(
					'before_kw'   => "\033[1;33m",
					'after_kw'    => "\033[0m",
					'before_qt'   => "\033[36m",
					'after_qt'    => "\033[0m",
					'before_bq'   => "\033[32m",
					'after_bq'    => "\033[0m",
					'before_info' => "\033[35m",
					'after_info'  => "\033[0m",
					'before_warn' => "\033[32m",
					'after_warn'  => "\033[0m",
					'after_q'     => "\n",
				);
			} else {
				$this->colors = array(
					'before_kw'   => '<span style="color: darkorange">',
					'after_kw'    => '</span>',
					'before_qt'   => '<span style="color: blue">',
					'after_qt'    => '</span>',
					'before_bq'   => '<span style="color: green">',
					'after_bq'    => '</span>',
					'before_info' => '<span style="color: gray">',
					'after_info'  => '</span>',
					'before_warn' => '<span style="color: red">',
					'after_warn'  => '</span>',
					'after_q'     => '<br>',
				);
			}
	}
开发者ID:vampirefrog,项目名称:BrickTracker,代码行数:37,代码来源:DB.php

示例9: __construct

 public function __construct($host = null, $user = null, $pass = null, $db = null)
 {
     if ($host === null) {
         ini_get("mysql.default_host");
     }
     if ($user === null) {
         ini_get("mysql.default_user");
     }
     if ($pass === null) {
         ini_get("mysql.default_password");
     }
     Instrumentation::get_instance()->increment('mysql_connection_count');
     Instrumentation::get_instance()->timer();
     parent::__construct($host, $user, $pass, $db);
     Instrumentation::get_instance()->increment('mysql_connect_time', Instrumentation::get_instance()->timer());
 }
开发者ID:hebaoxia,项目名称:instrumentation-for-php,代码行数:16,代码来源:Instrumentation.php

示例10: __construct

 /**
 	Class Construct : Connect to MySQL
 */
 public function __construct()
 {
     parent::__construct(BaseConfiguration::$MySQL["host"], BaseConfiguration::$MySQL["user"], BaseConfiguration::$MySQL["pass"], BaseConfiguration::$MySQL["db"]);
 }
开发者ID:44kia244,项目名称:MWFramework,代码行数:7,代码来源:DBengine.class.php

示例11: __construct

 /**
  * The constructor will create a new connection with the predefined
  * connection details. It's private because of the Singleton pattern.
  */
 public function __construct()
 {
     $aConfiguration = Configuration::getInstance()->get('LVPDatabase');
     parent::__construct($aConfiguration['hostname'], $aConfiguration['username'], $aConfiguration['password'], $aConfiguration['database']);
 }
开发者ID:LVPlayground,项目名称:bot-saber,代码行数:9,代码来源:LVPDatabase.php

示例12: __construct

 /**
  * Prefents the database class from being instantiated multiple times
  */
 private function __construct()
 {
     $settings = Config::get('database');
     return parent::__construct($settings['host'], $settings['user'], $settings['pass'], $settings['name']);
 }
开发者ID:priestd09,项目名称:sleekmvc,代码行数:8,代码来源:Database.php

示例13: __construct

 /**
  * Opens connection, sets UTF-8, and autocommit to false
  *
  */
 public function __construct($host = null, $user = null, $pass = null, $db = null, $port = null, $socket = null)
 {
     parent::__construct($host, $user, $pass, $db, $port, $socket);
     $this->set_charset('utf8');
     $this->autocommit(false);
 }
开发者ID:openwebsolns,项目名称:myorm,代码行数:10,代码来源:DBConnection.php

示例14: isset

 /**
  * Skapa en databas-anslutning.
  *
  * Laddar inställningar från global $repo_root/db_settings/$db_alias.php.
  * $host, $user, $passwd och $dbname förväntas vara satta.
  *
  * @param string $db_alias namnet på anslutningen du vill skapa. (dvs db_settings/$db_alias.php).
  */
 function __construct($db_alias, $debug = false)
 {
     global $repo_root, $notify;
     $this->do_debug = $debug;
     $settings_basefile = $repo_root . '/db_settings/' . $db_alias;
     $settings_file = $settings_basefile . '.php';
     $settings_localfile = $settings_basefile . '.local.php';
     require $settings_file;
     if (file_exists($settings_localfile)) {
         require $settings_localfile;
     }
     $this->db = $dbname;
     $this->host = $host;
     $this->port = isset($port) ? $port : 3306;
     $this->charset = $charset;
     $this->start_timer();
     parent::__construct($host, $user, $passwd, $dbname, $this->port);
     $this->stop_timer();
     if (mysqli_connect_errno()) {
         if ($this->do_debug) {
             $debuginfo = debug_backtrace();
             $debuginfo = $debuginfo[0];
             print "<p>MySQLi connection problem: " . mysqli_connect_errno() . " (" . mysqli_connect_error() . ").<br />" . "Problem encountered when trying to connect to " . $this->host . ":" . $this->port . ", database " . $this->db . ".<br />" . "The error was encountered in " . $debuginfo['file'] . ":" . $debuginfo['line'] . "<br /></p>";
             debug_print_backtrace();
         } else {
             $notify->admin_alert("Could not connect to SQL database: " . mysqli_connect_errno() . " (" . mysqli_connect_error() . ").", false);
         }
         die('<p>Kunde inte ansluta till databasen. Var god kontakta oss.</p>');
     }
     $this->start_timer();
     if (!parent::set_charset($charset)) {
         if ($this->do_debug) {
             $debuginfo = debug_backtrace();
             $debuginfo = $debuginfo[0];
             print "<p>MySQLi connection problem trying to set charset to \"{$charset}\": " . mysqli_errno() . " (" . mysqli_error() . ").<br />" . "The error was encountered in " . $debuginfo['file'] . ":" . $debuginfo['line'] . "<br /></p>";
             debug_print_backtrace();
         } else {
             $notify->admin_alert("Could not set charset for database connection: " . mysqli_errno() . " (" . mysqli_error() . ").", false);
         }
         die('<p>Ett problem uppstod med databasanslutningen. Var god kontakta oss.</p>');
     }
     $this->stop_timer();
     unset($user);
     unset($host);
     unset($passwd);
     unset($dbname);
     unset($charset);
 }
开发者ID:nibssolutions,项目名称:Nitroxy-retail-system,代码行数:56,代码来源:DatabaseConnectioni.php

示例15:

 function __construct()
 {
     parent::__construct('*', '*', '*');
     parent::select_db('zs1jas_1');
     parent::query("SET NAMES utf8");
 }
开发者ID:b4naser,项目名称:social_website,代码行数:6,代码来源:database.class.php


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