本文整理汇总了PHP中mysqli::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli::__construct方法的具体用法?PHP mysqli::__construct怎么用?PHP mysqli::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqli
的用法示例。
在下文中一共展示了mysqli::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($host, $user, $pass, $db)
{
parent::__construct($host, $user, $pass, $db);
if (mysqli_connect_error()) {
die('No se pudo conectar a la base de datos (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}
}
示例2: abrir
public function abrir()
{
parent::__construct($dbhost = 'p:localhost', $dbuser = 'root', $dbpass = '12345', $dbname = 'usuario');
$this->connect_errno ? die('Error con la conexión') : ($x = 'Conectado');
//echo $x;
unset($x);
}
示例3: __construct
public function __construct()
{
parent::__construct('localhost', 'root', '', 'xnova');
$this->query("SET NAMES utf8;");
date_default_timezone_set('America/Caracas');
$this->connect_errno ? die('ERROR: Datos incorrectos en /core/models/class.Connect.php') : null;
}
示例4: __construct
public function __construct($host, $user, $password, $database)
{
$link_id = @parent::__construct($host, $user, $password, $database);
if (mysqli_connect_error()) {
die('<b>Fehler beim Verbinden!</b><br>Connect Errno: ' . mysqli_connect_errno() . '<br>Connect Error: ' . mysqli_connect_error());
}
}
示例5: __construct
public function __construct($host = false, $user = false, $pass = false, $dbname = "", $port = false, $socket = false)
{
if ($host === false && $socket === false) {
$host = ini_get("mysqli.default_host");
}
if ($user === false) {
$user = ini_get("mysqli.default_user");
}
if ($pass === false) {
$pass = ini_get("mysqli.default_pw");
}
if ($port === false) {
$port = ini_get("mysqli.default_port");
}
if ($socket === false && $host === false) {
$socket = ini_get("mysqli.default_socket");
}
parent::__construct($host, $user, $pass, $dbname, $port, $socket);
if ($this->connect_error) {
throw new Expection('mysqlii: Connect Error (' . $this->connect_errno . ') ' . $this->connect_error);
}
#initialise the connection for killing queries
$this->killConnection = new mysqli($host, $user, $pass, $dbname, $port, $socket);
if ($this->killConnection->connect_error) {
throw new Expection('mysqlii: Connect Error in Kill Connection (' . $this->killConnection->connect_errno . ') ' . $this->{$killConnection}->connect_error);
}
}
示例6: __construct
/**
* Adb constructor.
*
* Function to establish a connection each time
* the adb class is instantiated. The constructor
* takes in the host, username, password, the name
* of the database and the port as its parameters
*
* @internal param string $host
* @internal param string $username
* @internal param string $passwd
* @internal param string $dbname
* @internal param int $port
*/
public function __construct()
{
parent::__construct(DB_HOST, DB_USER, DB_PWORD, DB_NAME, DB_PORT);
if (mysqli_connect_error()) {
die('Connection Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}
}
示例7: die
function __construct($host, $user, $pass, $db)
{
parent::__construct($host, $user, $pass, $db);
if ($this->connect_error) {
die('Connect Error (' . $this->connect_errno . ') ' . $this->connect_error);
}
}
示例8: __construct
private function __construct()
{
@parent::__construct(core_settings::i()->get('CONFIG_SERVERS_DATABASE_IP'), core_settings::i()->get('CONFIG_SERVERS_DATABASE_USERNAME'), core_settings::i()->get('CONFIG_SERVERS_DATABASE_PASSWORD'), core_settings::i()->get('CONFIG_SERVERS_DATABASE_DATABASE'), core_settings::i()->get('CONFIG_SERVERS_DATABASE_PORT'));
if ($this->connect_errno) {
throw new Exception("Cannot Connect to Database: " . $this->connect_error);
}
}
示例9:
/**
* @name __construct
* @param $host host for the mysql connection
* @param $user user for the mysql connection
* @param @pass password for the mysql connection
* @param $db schema to work with
* @param $port port for the mysql connection
* @param $socket socket for the mysql connection
**/
function __construct($host = 'localhost', $user = null, $pass = null, $db = null, $port = null, $socket = null)
{
@parent::__construct($host, $user, $pass, $db, $port, $socket);
if ($this->connect_errno != 0) {
$this->build_error('connect');
}
}
示例10: __construct
public function __construct($options = array())
{
$default = array('mysql_data' => NULL, 'repertoire' => '/');
$options = array_merge($default, $options);
extract($options);
$this->host = $mysql_data['host'];
$this->port = $mysql_data['port'];
$this->user = $mysql_data['user'];
$this->pass = $mysql_data['pass'];
$this->bdd = $mysql_data['bdd'];
$this->socket = $mysql_data['socket'];
$this->charset = $mysql_data['charset'];
$this->collation = $mysql_data['collation'];
$this->data_directory = $mysql_data['data_directory'];
@parent::__construct($this->host, $this->user, $this->pass, $this->bdd, $this->port, $this->socket);
if ($this->connect_error) {
$this->bkp_errors[] = 'Une erreur s\'est produite lors de la connexion aux bases de données';
return;
}
$this->repertoire = $repertoire;
if (!is_dir($this->repertoire)) {
$this->bkp_errors[] = 'Une erreur s\'est produite lors l\'accès au répertoire « ' . htmlspecialchars($this->repertoire) . ' »';
return;
}
$this->nom_fichier = $this->bdd . '.sql';
$this->fichier = @fopen($this->repertoire . $this->nom_fichier, 'w');
if (!$this->fichier) {
$this->bkp_errors[] = 'Une erreur s\'est produite lors de l\'écriture du fichier "' . htmlspecialchars($this->nom_fichier) . '"';
return;
}
$this->generer();
$this->bkp_errors = array();
}
示例11: __construct
public function __construct()
{
parent::__construct(HOST, NOMUSUARI, CONTRASENYA, NOMBDD);
if (mysqli_connect_error()) {
die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}
}
示例12: __construct
public function __construct($host, $username, $password, $database)
{
parent::__construct("{$host}", "{$username}", "{$password}", "{$database}");
if (mysqli_connect_error()) {
die('Could not connect: ' . mysqli_connect_error());
}
}
示例13: __construct
/**
* Constructeur
* @param array $options
*/
public function __construct($options = array())
{
$default = array('host' => ini_get('mysqli.default_host'), 'username' => ini_get('mysqli.default_user'), 'passwd' => ini_get('mysqli.default_pw'), 'dbname' => '', 'port' => ini_get('mysqli.default_port'), 'socket' => ini_get('mysqli.default_socket'), 'dossier' => './sql/', 'nbr_fichiers' => 5, 'nom_fichier' => 'backup_');
$options = array_merge($default, $options);
extract($options);
// Connexion de la connexion DB
@parent::__construct($host, $username, $passwd, $dbname, $port, $socket);
if ($this->connect_error) {
$this->message('Erreur de connexion (' . $this->connect_errno . ') ' . $this->connect_error);
return;
}
// Controle du dossier
$this->dossier = $dossier;
if (!is_dir($this->dossier)) {
$this->message('Erreur de dossier "' . htmlspecialchars($this->dossier) . '"');
return;
}
// Controle du fichier
$this->nom_fichier = $nom_fichier . date('Ymd-His') . '.sql.gz';
$this->gz_fichier = @gzopen($this->dossier . $this->nom_fichier, 'w');
if (!$this->gz_fichier) {
$this->message('Erreur de fichier "' . htmlspecialchars($this->nom_fichier) . '"');
return;
}
// Demarrage du traitement
$this->sauvegarder();
$this->purger_fichiers($nbr_fichiers);
}
示例14: __construct
private function __construct()
{
parent::__construct(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if (mysqli_connect_errno()) {
throw new Exception(mysqli_connect_error(), mysqli_connect_errno());
}
}
示例15: die
function __construct()
{
parent::__construct("henrikh.dyndns.org", "webprosjekt", "web123", "web_prosjekt", "3306");
if (mysqli_connect_error()) {
die("Kunne ikke opprette tilkobling til databasen: (" . mysqli_connect_errno() . ") " . mysqli_connect_error());
}
}