/** * 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); } }
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); } }
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); }
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 = ''"); }
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); }
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); } }
/** * 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"); }
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>', ); } }
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()); }
/** Class Construct : Connect to MySQL */ public function __construct() { parent::__construct(BaseConfiguration::$MySQL["host"], BaseConfiguration::$MySQL["user"], BaseConfiguration::$MySQL["pass"], BaseConfiguration::$MySQL["db"]); }
/** * 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']); }
/** * 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']); }
/** * 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); }
/** * 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); }
function __construct() { parent::__construct('*', '*', '*'); parent::select_db('zs1jas_1'); parent::query("SET NAMES utf8"); }
function __construct($host, $username, $password, $database, $port = 3306, $socket = '') { parent::__construct($host, $username, $password, $database, $port, $socket); $message = sprintf('connect to mysql,host:%s,port:%s,username:%s,password:%s,database:%s', $host, $port, $username, $password, $database); Debugger::getInstance()->debug($message); }
private function __construct($host, $user, $password, $database) { parent::__construct($host, $user, $password, $database); }
public function __construct() { parent::__construct(Configuration::$databaseHost, Configuration::$databaseUsername, Configuration::$databasePassword, Configuration::$databaseName); }