本文整理汇总了PHP中mysqli_report函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_report函数的具体用法?PHP mysqli_report怎么用?PHP mysqli_report使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysqli_report函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: isInstalled
public function isInstalled()
{
if (!$this->isConfigured() or !$this->db) {
return FALSE;
}
try {
if (!$this->db->isConnected()) {
mysqli_report(MYSQLI_REPORT_ALL);
$this->db->connect(FALSE);
}
} catch (ServiceException $e) {
return FALSE;
}
if (!$this->db->databaseExists()) {
return FALSE;
}
try {
$this->db->selectDb();
} catch (ServiceException $e) {
Logging::logDebug('Mollify not installed');
return FALSE;
}
try {
$ver = $this->dbUtil->installedVersion();
} catch (ServiceException $e) {
Logging::logDebug('Mollify not installed');
return FALSE;
}
if ($ver != NULL) {
Logging::logDebug('Mollify installed version: ' . $ver);
} else {
Logging::logDebug('Mollify not installed');
}
return $ver != NULL;
}
开发者ID:kumarsivarajan,项目名称:mollify,代码行数:35,代码来源:MySQLInstaller.class.php
示例2: __construct
public function __construct($charset, $handler = null)
{
\mysqli_report(MYSQLI_REPORT_OFF);
$this->charset = $charset;
$this->connection = null;
$this->handler = $handler;
}
开发者ID:BidTorrent,项目名称:api,代码行数:7,代码来源:mysqli.php
示例3: Init
public static function Init($sServer, $sUser, $sPwd, $sSource = '')
{
self::$m_sDBHost = $sServer;
self::$m_sDBUser = $sUser;
self::$m_sDBPwd = $sPwd;
self::$m_sDBName = $sSource;
self::$m_oMysqli = null;
mysqli_report(MYSQLI_REPORT_STRICT);
// *some* errors (like connection errors) will throw mysqli_sql_exception instead
// of generating warnings printed to the output but some other errors will still
// cause the query() method to return false !!!
try {
$aConnectInfo = explode(':', self::$m_sDBHost);
if (count($aConnectInfo) > 1) {
// Override the default port
$sServer = $aConnectInfo[0];
$iPort = (int) $aConnectInfo[1];
self::$m_oMysqli = new mysqli($sServer, self::$m_sDBUser, self::$m_sDBPwd, '', $iPort);
} else {
self::$m_oMysqli = new mysqli(self::$m_sDBHost, self::$m_sDBUser, self::$m_sDBPwd);
}
} catch (mysqli_sql_exception $e) {
throw new MySQLException('Could not connect to the DB server', array('host' => self::$m_sDBHost, 'user' => self::$m_sDBUser), $e);
}
if (!empty($sSource)) {
try {
mysqli_report(MYSQLI_REPORT_STRICT);
// Errors, in the next query, will throw mysqli_sql_exception
self::$m_oMysqli->query("USE `{$sSource}`");
} catch (mysqli_sql_exception $e) {
throw new MySQLException('Could not select DB', array('host' => self::$m_sDBHost, 'user' => self::$m_sDBUser, 'db_name' => self::$m_sDBName), $e);
}
}
}
开发者ID:henryavila,项目名称:itop,代码行数:34,代码来源:cmdbsource.class.inc.php
示例4: initialise
static function initialise($ConfigFile)
{
if ($initialised) {
return;
}
// Run this only once!
include $ConfigFile;
$host = $conf['database_host'];
$db = $conf['database_name'];
$user = $conf['database_login'];
$pass = $conf['database_pass'];
CSession::$session_timeout = $conf['session_timeout_sec'];
// connect to mysql and open database
CSession::$db_link = mysql_connect($host, $user, $pass) or die("Couldn't connect to the database");
@mysql_select_db($db, CSession::$db_link) or die("Unable to select database");
// // Create a db connection using PDO. Should migrate everything over to use PDO.
// CSession::$pdo_dbh = new PDO("mysql:host=$host;dbname=$db", $user, $pass);
// Connection using mysqli for the newer code. Should move all mysql code to mysqli!
mysqli_report(MYSQLI_REPORT_STRICT);
try {
CSession::$dbh = new mysqli($host, $user, $pass, $db);
if (CSession::$dbh->connect_errno) {
die("FAILED TO CONNECT TO THE DB. ERROR: " . CSession::$dbh->connect_error);
exit;
}
} catch (mysqli_sql_exception $e) {
die("FAILED TO CONNECT TO THE DB. ERROR: " . $e->getMessage());
}
}
开发者ID:robertohernando,项目名称:phpchess,代码行数:29,代码来源:CSession.php
示例5: query
/**
* Выполнение запроса к базе данных, выполняет коннект на запросе
*
* @param string $query
* @param array $params
* @param int $shard_id
* @throws Exception
*/
public static function query($query, array $params = [], $shard_id = 0)
{
assert("is_string(\$query)");
assert("\\is_array(\$params)");
assert("is_int(\$shard_id)");
assert("\$shard_id >= 0 && \$shard_id < 4096 /* only 4096 shards allowed */");
static $time = 0;
if (!static::$shards) {
static::$shards = config('mysql.shard');
}
if (!static::$pool) {
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
}
if (!isset(static::$shards[$shard_id])) {
trigger_error('No shards for mysql server specified');
}
// Если на этом шарде еще коннетка нет
if (!isset(static::$pool[$shard_id])) {
$dsn =& static::$shards[$shard_id];
$dsn_key = function ($key) use($dsn) {
preg_match("|{$key}=([^;]+)|", $dsn, $m);
return $m ? $m[1] : null;
};
$DB =& static::$pool[$shard_id];
$DB = mysqli_init();
$DB->options(MYSQLI_OPT_CONNECT_TIMEOUT, config('mysql.connect_timeout'));
$DB->real_connect($dsn_key('host'), $dsn_key('user'), $dsn_key('password'), $dsn_key('dbname'), $dsn_key('port'));
}
$DB =& static::$pool[$shard_id];
if (range(0, sizeof($params) - 1) === array_keys($params)) {
$query = preg_replace_callback('|\\?|', function () {
static $count = 0;
return ':' . $count++;
}, $query);
}
$params = array_combine(array_map(function ($k) {
return ':' . $k;
}, array_keys($params)), array_map(function ($item) use($DB) {
return filter_var($item, FILTER_VALIDATE_INT | FILTER_VALIDATE_FLOAT | FILTER_VALIDATE_BOOLEAN) ? $item : '"' . $DB->real_escape_string($item) . '"';
}, $params));
$Result = $DB->query(strtr($query, $params));
// Определяем результат работы функции в зависимости от типа запроса к базе
switch (strtolower(strtok($query, ' '))) {
case 'insert':
return $DB->insert_id ?: $DB->affected_rows;
break;
case 'update':
case 'delete':
return $DB->affected_rows;
break;
case 'select':
case 'describe':
$result = $Result->fetch_all(MYSQLI_ASSOC);
$Result->close();
return $result;
break;
default:
trigger_error('Undefined call for database query');
}
}
开发者ID:dmitrykuzmenkov,项目名称:kisscore-plugin-DB,代码行数:68,代码来源:DB.php
示例6: __construct
/**
* Create a new Mysqli object.
*
* @param array $params
* @return object
*/
public function __construct($key)
{
mysqli_report(MYSQLI_REPORT_STRICT);
$params = Config::get('mysql.' . $key);
if ($params === null && IS_SUBSITE) {
$params = MainConfig::get('mysql.' . $key);
}
if ($params === null) {
$params = [];
}
parent::init();
$params['pass'] = isset($params['pass']) ? $params['pass'] : '';
$params['user'] = isset($params['user']) ? $params['user'] : 'root';
$params['host'] = isset($params['host']) ? $params['host'] : '127.0.0.1';
$params['port'] = isset($params['port']) ? $params['port'] : 3306;
$params['timeout'] = isset($params['timeout']) ? $params['timeout'] : 30;
$params['charset'] = isset($params['charset']) ? $params['charset'] : 'utf8';
$params['database'] = isset($params['database']) ? $params['database'] : false;
parent::options(MYSQLI_OPT_CONNECT_TIMEOUT, $params['timeout']);
parent::real_connect($params['host'], $params['user'], $params['pass'], $params['database'], $params['port']);
if ($this->errno === 0) {
$this->set_charset($params['charset']);
if (isset($params['cache']) && $params['cache'] === false) {
$this->cache(false);
}
}
}
开发者ID:Gimle,项目名称:gimle5,代码行数:33,代码来源:mysql.php
示例7: __construct
public function __construct($host, $user, $pass, $dbname, $charset = "utf8", $debug = true, $errormsg = "Database connection failed.")
{
//if debugging errors show error report
if ($this->debug) {
mysqli_report(MYSQLI_REPORT_ERROR);
} else {
mysqli_report(MYSQLI_REPORT_OFF);
}
//making connection
$this->connection = @new mysqli($host, $user, $pass, $dbname);
//if conn error populating property conn_error with the results of connect_error function
$this->connection_error = $this->connection->connect_error;
$this->connection_error_code = $this->connection->connect_errno;
$this->debug = $debug;
if (!$this->connection_error_code) {
$this->connection->set_charset($charset);
if ($charset == "utf8") {
$this->connection->query("SET NAMES utf8");
}
$this->server_info = $this->connection->server_info;
$this->client_info = $this->connection->client_info;
$this->host_info = $this->connection->host_info;
} else {
if ($this->connection_error_code && $errormsg !== false) {
error_log("MySQL database error: " . $this->connection_error . " for error code " . $this->connection_error_code);
if ($this->debug) {
die("Database Connection Error " . $this->connection_error_code . ": " . $this->connection_error);
} else {
die($errormsg);
}
}
}
}
开发者ID:raulrene,项目名称:sfaw-test,代码行数:33,代码来源:database.php
示例8: __construct
function __construct()
{
$tables = null;
if (!defined(GODTABLE) || !defined(PHANETONTABLE) || !defined(ITEMTABLE) || !defined(BUILDTABLE) || !defined(SKILLTABLE) || !defined(BUILDLVLTABLE) || !defined(BUILDITEMTABLE) || !defined(EFFECTITEMTABLE)) {
$tables = array(GODTABLE, PHANETONTABLE, ITEMTABLE, BUILDTABLE, SKILLTABLE, BUILDLVLTABLE, BUILDITEMTABLE, EFFECTITEMTABLE);
} else {
$this->insertIntoArray(Database::$error_array['defNotSet']);
}
if (!defined(USER_NAME) || !define(USER_PASSWORD) || !defined(DATABASE) || !defined(SERVER_ADDRESS) || !defined(DATABASE_PORT)) {
} else {
$this->insertIntoArray(Database::$error_array['dbInfo']);
}
mysqli_report(MYSQLI_REPORT_STRICT);
try {
$this->connection = new mysqli(SERVER_ADDRESS, USER_NAME, USER_PASSWORD, DATABASE, DATABASE_PORT);
} catch (Exception $ex) {
$this->insertIntoArray($ex);
}
//$this->setSQLTimezone($this->connection);
if ($this->connection && $this->connection->connect_error) {
$this->connection = null;
$this->insertIntoArray(Database::$error_array['db']);
}
if (!empty($tables)) {
foreach ($tables as $table) {
if (!empty($table)) {
$this->checkIfTableExists($table);
}
}
}
$this->tables = $this->getTables();
}
开发者ID:Nyranith,项目名称:Overload-Factory,代码行数:32,代码来源:_Database.php
示例9: connect
/**
* connect
* @access public
* @param array $config
* @param integer $linknum
* @return mixed
*/
public function connect($config = null, $linknum = 0)
{
$config = $this->dbconfig($config, $linknum);
$linknum = isset($config['linknum']) ? $config['linknum'] : 0;
if (isset($this->_linkids[$linknum])) {
return $this->_linkid = $this->_linkids[$linknum];
}
if (empty($config['dbname'])) {
trigger_error('Mysqli DSN configure error', E_USER_ERROR);
return false;
}
$config['host'] = empty($config['host']) ? 'localhost' : $config['host'];
$config['user'] = empty($config['user']) ? '' : $config['user'];
$config['pass'] = empty($config['pass']) ? '' : $config['pass'];
$config['port'] = empty($config['port']) ? 3306 : intval($config['port']);
$config['charset'] = empty($config['charset']) ? 'utf8' : $config['charset'];
$this->_linkids[$linknum] = new mysqli($config['host'], $config['user'], $config['pass'], $config['dbname'], $config['port']);
if (mysqli_connect_errno()) {
trigger_error(mysqli_connect_error(), E_USER_ERROR);
return false;
}
$dbversion = $this->_linkids[$linknum]->server_version;
$this->_linkids[$linknum]->query("SET NAMES '{$config['charset']}'");
if ($dbversion > '5.0.1') {
$this->_linkids[$linknum]->query("SET sql_mode=''");
}
mysqli_report(MYSQLI_REPORT_ERROR);
return $this->_linkid = $this->_linkids[$linknum];
}
开发者ID:zxy2543,项目名称:yodphp,代码行数:36,代码来源:DbMysqli.php
示例10: run
/**
* run
*
* @param Event $event
*/
public static function run(Event $event = null)
{
$io = self::getIO($event);
if (!file_exists($file_path = rtrim(APPPATH, '/') . '/config/database.php')) {
$io->write('<error>The configuration file database.php does not exist.</error>');
}
include $file_path;
if (!isset($active_group)) {
$io->write('<error>You have not specified a database connection group via $active_group in your config/database.php file.</error>');
}
$hostname = $db[$active_group]['hostname'];
$username = $db[$active_group]['username'];
$password = $db[$active_group]['password'];
$database = $db[$active_group]['database'];
try {
mysqli_report(MYSQLI_REPORT_STRICT);
$mysqli = new \mysqli($hostname, $username, $password);
$io->write(sprintf('<comment>Connected to %s:%s.</comment> ', $hostname, $database));
$sql_script_path = $io->ask('<question>Enter your SQl script path :</question> ', null);
self::execute_script($mysqli, $db[$active_group], $sql_script_path);
$io->write('<info>The script was executed successfully.</info>');
} catch (\Exception $e) {
$io->write('<error>' . $e->getMessage() . '</error>');
}
}
开发者ID:lidaa,项目名称:codeigniter-standard-edition,代码行数:30,代码来源:Run_Sql.php
示例11: __construct
public function __construct($database, $host, $user, $password, $charset = "utf8", $debug = true, $errormsg = "Database connection failed.")
{
if ($this->debug) {
mysqli_report(MYSQLI_REPORT_ERROR);
} else {
mysqli_report(MYSQLI_REPORT_OFF);
}
$this->connection = @new mysqli($host, $user, $password, $database);
$this->connection_error = $this->connection->connect_error;
$this->connection_error_code = $this->connection->connect_errno;
$this->debug = $debug;
if (!$this->connection_error_code) {
$this->connection->set_charset($charset);
if ($charset == "utf8") {
$this->connection->query("SET NAMES utf8");
}
$this->server_info = $this->connection->server_info;
$this->client_info = $this->connection->client_info;
$this->host_info = $this->connection->host_info;
} else {
if ($this->connection_error_code && $errormsg !== false) {
error_log("MySQL database error: " . $this->connection_error . " for error code " . $this->connection_error_code);
if ($this->debug) {
die("Database Connection Error " . $this->connection_error_code . ": " . $this->connection_error);
} else {
die($errormsg);
}
}
}
}
开发者ID:raulrene,项目名称:sfaw-test,代码行数:30,代码来源:database.php
示例12: __construct
public function __construct($database, $username = '', $password = '', $server = 'localhost')
{
$this->mysqli = new mysqli($server, $username, $password, $database);
if (mysqli_connect_errno() !== 0) {
throw new Exception(mysqli_connect_error(), mysqli_connect_errno());
}
mysqli_report(MYSQLI_REPORT_ERROR);
}
开发者ID:BackupTheBerlios,项目名称:phpalmanac-svn,代码行数:8,代码来源:mysql.lib.php
示例13: connect
/**
* If the Database timed our for any reason, we protect errors by closing out
* the socket to the Database through the MySQLi object. Otherwise, this
* handles connecting to the MySQL database specified in the config file.
*/
public static function connect()
{
self::disconnect();
//throw errors, but not too many
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
self::$_mysql = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
self::$_mysql->autocommit(false);
}
开发者ID:jugglinmike,项目名称:ae-framework,代码行数:13,代码来源:database.php
示例14: __construct
/**
* Connection constructor.
*
* @param $config string[]
*/
public function __construct($config)
{
mysqli_report(MYSQLI_REPORT_STRICT);
// attempt to connect to the db
$this->mysqli = new \mysqli($config['host'], $config['user'], $config['password'], $config['database'], $config['port']);
// we will manually commit our sql changes
$this->mysqli->autocommit(false);
$this->statementCache = new Statement(500);
}
开发者ID:justin-robinson,项目名称:scoop,代码行数:14,代码来源:connection.php
示例15: connect
public function connect()
{
try {
mysqli_report(MYSQLI_REPORT_STRICT);
$this->cnx = new \mysqli(parse_url($this->connectionString, PHP_URL_HOST), parse_url($this->connectionString, PHP_URL_USER), parse_url($this->connectionString, PHP_URL_PASS), parse_url($this->connectionString, PHP_URL_FRAGMENT), parse_url($this->connectionString, PHP_URL_PORT), parse_url($this->connectionString, PHP_URL_PATH));
} catch (\mysqli_sql_exception $ex) {
throw new ConnectionFailedException($ex->getMessage(), $ex->getCode(), $ex);
}
}
开发者ID:sndatabase,项目名称:mysql,代码行数:9,代码来源:MySQLiConnection.php
示例16: __construct
public function __construct()
{
$params = (include ROOT . '/config/db_params.php');
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$this->db = new mysqli($params['host'], $params['user'], $params['password'], $params['dbname']);
if (mysqli_connect_errno()) {
exit;
}
}
开发者ID:bogwien,项目名称:first.mystore.loc,代码行数:9,代码来源:Db.php
示例17: connect
/**
* Connects to a database.
* @return void
* @throws DibiException
*/
public function connect(array &$config)
{
mysqli_report(MYSQLI_REPORT_OFF);
if (isset($config['resource'])) {
$this->connection = $config['resource'];
} else {
// default values
$config += array('charset' => 'utf8', 'timezone' => date('P'), 'username' => ini_get('mysqli.default_user'), 'password' => ini_get('mysqli.default_pw'), 'socket' => ini_get('mysqli.default_socket'), 'port' => NULL);
if (!isset($config['host'])) {
$host = ini_get('mysqli.default_host');
if ($host) {
$config['host'] = $host;
$config['port'] = ini_get('mysqli.default_port');
} else {
$config['host'] = NULL;
$config['port'] = NULL;
}
}
$foo =& $config['flags'];
$foo =& $config['database'];
$this->connection = mysqli_init();
if (isset($config['options'])) {
if (is_scalar($config['options'])) {
$config['flags'] = $config['options'];
// back compatibility
trigger_error(__CLASS__ . ": configuration item 'options' must be array; for constants MYSQLI_CLIENT_* use 'flags'.", E_USER_NOTICE);
} else {
foreach ((array) $config['options'] as $key => $value) {
mysqli_options($this->connection, $key, $value);
}
}
}
@mysqli_real_connect($this->connection, (empty($config['persistent']) ? '' : 'p:') . $config['host'], $config['username'], $config['password'], $config['database'], $config['port'], $config['socket'], $config['flags']);
// intentionally @
if ($errno = mysqli_connect_errno()) {
throw new DibiDriverException(mysqli_connect_error(), $errno);
}
}
if (isset($config['charset'])) {
$ok = FALSE;
if (version_compare(PHP_VERSION, '5.1.5', '>=')) {
// affects the character set used by mysql_real_escape_string() (was added in MySQL 5.0.7 and PHP 5.0.5, fixed in PHP 5.1.5)
$ok = @mysqli_set_charset($this->connection, $config['charset']);
// intentionally @
}
if (!$ok) {
$this->query("SET NAMES '{$config['charset']}'");
}
}
if (isset($config['sqlmode'])) {
$this->query("SET sql_mode='{$config['sqlmode']}'");
}
if (isset($config['timezone'])) {
$this->query("SET time_zone='{$config['timezone']}'");
}
$this->buffered = empty($config['unbuffered']);
}
开发者ID:besir,项目名称:besir.cz,代码行数:62,代码来源:DibiMySqliDriver.php
示例18: connect
function connect($server, $username, $password)
{
mysqli_report(MYSQLI_REPORT_OFF);
// stays between requests, not required since PHP 5.3.4
list($host, $port) = explode(":", $server, 2);
// part after : is used for port or socket
$this->ssl_set(NULL, NULL, NULL, NULL, "AES256-SHA");
$return = @$this->real_connect($server != "" ? $host : ini_get("mysqli.default_host"), $server . $username != "" ? $username : ini_get("mysqli.default_user"), $server . $username . $password != "" ? $password : ini_get("mysqli.default_pw"), null, is_numeric($port) ? $port : ini_get("mysqli.default_port"), !is_numeric($port) ? $port : null, MYSQLI_CLIENT_SSL);
return $return;
}
开发者ID:tomec-martin,项目名称:adminer,代码行数:10,代码来源:mysqlssl.inc.php
示例19: __construct
public function __construct()
{
mysqli_report(MYSQLI_REPORT_STRICT);
try {
$this->MySQLi = new mysqli($this->host, $this->username, $this->password, $this->database);
} catch (Exception $e) {
echo "Error Code: " . $e->getCode();
echo "<br>Error Message: " . $e->getMessage();
}
}
开发者ID:gylmax,项目名称:IF-Pictures,代码行数:10,代码来源:MySQLi.class.php
示例20: connect
public function connect($host, $user, $password, $database)
{
mysqli_report(MYSQLI_REPORT_STRICT);
try {
$this->mysqli = new \mysqli($host, $user, $password, $database);
//$this->query('SET NAMES utf8');
} catch (\mysqli_sql_exception $e) {
throw new Exception\ConnectionException('Mysql connection failed.');
}
}
开发者ID:veloxpro,项目名称:VeloxPHP,代码行数:10,代码来源:Driver.php
注:本文中的mysqli_report函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论