本文整理汇总了PHP中MySQLi::close方法的典型用法代码示例。如果您正苦于以下问题:PHP MySQLi::close方法的具体用法?PHP MySQLi::close怎么用?PHP MySQLi::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySQLi
的用法示例。
在下文中一共展示了MySQLi::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: disconnect
public function disconnect()
{
Logger::getInstance()->log('Disconnecting database.');
if (isset($this->connection)) {
$this->connection->close();
}
$this->connection = null;
}
示例2: close
/**
* Fecha a conexão com o banco de dados.
*
* @return void
*/
public function close()
{
if ($this->isConnected()) {
$this->connection->close();
unset($this->connection);
$this->connection = null;
}
}
示例3: _validateMysqli
private function _validateMysqli($data)
{
$conn = new \MySQLi($data['db_hostname'], $data['db_username'], $data['db_password']);
if ($conn->connect_error) {
$conn->close();
return false;
} else {
// Try to create database, if doesn't exist
$sql = "CREATE DATABASE IF NOT EXISTS " . $data['db_database'];
if ($conn->query($sql) === false) {
// Couldn't create it, just check if exists
$sql = "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '" . $data['db_database'] . "'";
if (!$conn->query($sql)->num_rows) {
$conn->close();
return false;
}
}
$conn->close();
return true;
}
}
示例4: close
/**
* Closes the connection to SphinxQL
*/
public function close()
{
$result = $this->_driver->close();
return $result;
}
示例5: close
/**
* Closes the database connection.
*/
public function close()
{
$this->_mysqli->close();
}
示例6: die
if ($len < 102400 || $len > 5 * 1024 * 1024) {
die("Pic size error! Allow size: 100KB to 5MB");
}
$ip = substr($_SERVER['REMOTE_ADDR'], 0, 49);
$pic = base64_decode($pic_str);
unset($pic_str);
$name = date('YmdHis', time());
$dir = 'img/' . date('Y/m/d', time());
$url = $dir . '/' . substr($name, 8) . '_' . uniqid() . '.png';
$sql = "insert into p(ip,name,url,rotate) values(?,?,?,0)";
$con = new MySQLi(DB_HOST, DB_NAME, DB_USER, DB_PASS);
$res = $con->prepare($sql);
$res->bind_param("sss", $ip, $name, $url);
$res->execute();
$res->close();
$con->close();
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
$file = fopen($url, "wb");
fwrite($file, $pic);
fflush($file);
fclose($file);
$img = imagecreatefromstring($pic);
unset($pic);
$width = imagesx($img);
$height = imagesy($img);
$ratio = $height > $width ? 800 / $height : 800 / $width;
$resize_img = imagecreatetruecolor($width * $ratio, $height * $ratio);
imagecopyresampled($resize_img, $img, 0, 0, 0, 0, $width * $ratio, $height * $ratio, $width, $height);
imagejpeg($resize_img, $url . "rs");
示例7: array
//数据库类型
$host = 'localhost';
//数据库主机名
$user = 'root';
//数据库连接用户名
$pass = 'blog.benhuang1024.com';
$rpfield = 'body';
// update table char
$tostring = '';
//
$sql_arr = array(table1, table2);
$rpstring_arr = array('违规词1', '违规词2');
foreach ($rpstring_arr as $rpstring_one) {
$rpstring = $rpstring_one;
foreach ($sql_arr as $sql_one) {
$mysqli = new MySQLi($host, $user, $pass, $sql_one);
$mysqli->query("set names UTF8");
$exptable_obj = $mysqli->query("show tables like '%_addonarticle'");
// 获取表(内容表,标签表)
$exptable = mysqli_fetch_array($exptable_obj);
$exptable = $exptable[0];
$rs = $mysqli->query("UPDATE {$exptable} SET {$rpfield}=REPLACE({$rpfield},'{$rpstring}','{$tostring}')");
$mysqli->query("OPTIMIZE TABLE `{$exptable}`");
if ($rs) {
echo $sql_one . "成功完成 " . $rpstring . " 数据替换!<br />";
} else {
echo $sql_one . "中数据 " . $rpstring . " 替换失败!<br />";
}
$mysqli->close();
}
}
示例8: add_user
function add_user($Uname, $Upass, $Urole)
{
try {
$host = "localhost";
$user = "root";
$pwd = "root";
$db = "adminp";
$con = new MySQLi($host, $user, $pwd);
$con->select_db($db);
$Uname1 = $Uname;
$Uname = hash('md5', $Uname);
$Upass = hash('md5', $Upass);
$query = "insert into admin_users (u_name,u_pwd,u_role) values('" . $Uname . "','" . $Upass . "','" . $Urole . "')";
if ($con->query($query)) {
?>
<div class="alert alert-success fade in" style="text-align:left;"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a><strong>Success !</strong>Admin User is Added. USER :<?php
echo $Uname1;
?>
</div>
<?php
} else {
?>
<div class="alert alert-danger fade in" style="text-align:left;"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a><strong>Unsuccess !</strong>User already EXISTS</div>
<?php
}
} catch (Exception $ex) {
print "{$ex}";
}
$con->close();
}
示例9: __destruct
/**
* Destructor, disconnect from database
*/
public function __destruct()
{
@$this->dbcon->close();
}
示例10:
$t = preg_split("/(?<=\\w)\\b\\s*/", $row["time"]);
echo "Posted Date : ";
echo $t[0];
echo $t[1];
echo $t[2];
echo "<br><br>";
echo "Posted Time : ";
echo $t[3];
echo $t[4];
echo $t[5];
echo "<br><br>";
}
} else {
echo " Sorry, No jobs your searched area. ";
}
$conn->close();
//echo "Successfully";
}
?>
</center>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
示例11: db_connect
/**
* Database connection
*
* @param bool $persistent
* @return object
*/
public function db_connect($persistent = FALSE)
{
// Do we have a socket path?
if ($this->hostname[0] === '/') {
$hostname = NULL;
$port = NULL;
$socket = $this->hostname;
} else {
// Persistent connection support was added in PHP 5.3.0
$hostname = $persistent === TRUE && is_php('5.3') ? 'p:' . $this->hostname : $this->hostname;
$port = empty($this->port) ? NULL : $this->port;
$socket = NULL;
}
$client_flags = $this->compress === TRUE ? MYSQLI_CLIENT_COMPRESS : 0;
$this->_mysqli = mysqli_init();
$this->_mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 10);
if (isset($this->stricton)) {
if ($this->stricton) {
$this->_mysqli->options(MYSQLI_INIT_COMMAND, 'SET SESSION sql_mode = CONCAT(@@sql_mode, ",", "STRICT_ALL_TABLES")');
} else {
$this->_mysqli->options(MYSQLI_INIT_COMMAND, 'SET SESSION sql_mode =
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
@@sql_mode,
"STRICT_ALL_TABLES,", ""),
",STRICT_ALL_TABLES", ""),
"STRICT_ALL_TABLES", ""),
"STRICT_TRANS_TABLES,", ""),
",STRICT_TRANS_TABLES", ""),
"STRICT_TRANS_TABLES", "")');
}
}
if (is_array($this->encrypt)) {
$ssl = array();
empty($this->encrypt['ssl_key']) or $ssl['key'] = $this->encrypt['ssl_key'];
empty($this->encrypt['ssl_cert']) or $ssl['cert'] = $this->encrypt['ssl_cert'];
empty($this->encrypt['ssl_ca']) or $ssl['ca'] = $this->encrypt['ssl_ca'];
empty($this->encrypt['ssl_capath']) or $ssl['capath'] = $this->encrypt['ssl_capath'];
empty($this->encrypt['ssl_cipher']) or $ssl['cipher'] = $this->encrypt['ssl_cipher'];
if (!empty($ssl)) {
if (isset($this->encrypt['ssl_verify'])) {
if ($this->encrypt['ssl_verify']) {
defined('MYSQLI_OPT_SSL_VERIFY_SERVER_CERT') && $this->_mysqli->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, TRUE);
} elseif (defined('MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT')) {
$this->_mysqli->options(MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT, TRUE);
}
}
$client_flags |= MYSQLI_CLIENT_SSL;
$this->_mysqli->ssl_set(isset($ssl['key']) ? $ssl['key'] : NULL, isset($ssl['cert']) ? $ssl['cert'] : NULL, isset($ssl['ca']) ? $ssl['ca'] : NULL, isset($ssl['capath']) ? $ssl['capath'] : NULL, isset($ssl['cipher']) ? $ssl['cipher'] : NULL);
}
}
if (@$this->_mysqli->real_connect($hostname, $this->username, $this->password, $this->database, $port, $socket, $client_flags)) {
// Prior to version 5.7.3, MySQL silently downgrades to an unencrypted connection if SSL setup fails
if ($client_flags & MYSQLI_CLIENT_SSL && version_compare($this->_mysqli->client_info, '5.7.3', '<=') && empty($this->_mysqli->query("SHOW STATUS LIKE 'ssl_cipher'")->fetch_object()->Value)) {
$this->_mysqli->close();
$message = 'MySQLi was configured for an SSL connection, but got an unencrypted connection instead!';
log_message('error', $message);
return $this->db->db_debug ? $this->db->display_error($message, '', TRUE) : FALSE;
}
return $this->_mysqli;
}
return FALSE;
}
示例12:
function __destruct()
{
// mysqli_report(MYSQLI_REPORT_OFF);
parent::close();
}
示例13: json_encode
} else {
$slug = preg_replace('/[^a-z0-9]/si', '', $slug);
if (is_numeric($slug) && strlen($slug) > 8) {
$url = 'https://twitter.com/' . TWITTER_USERNAME . '/status/' . $slug;
} else {
$db = new MySQLi(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE);
$db->set_charset('utf8mb4');
$escapedSlug = $db->real_escape_string($slug);
$redirectResult = $db->query('SELECT url FROM redirect WHERE slug = "' . $escapedSlug . '"');
if ($redirectResult && $redirectResult->num_rows > 0) {
$db->query('UPDATE redirect SET hits = hits + 1 WHERE slug = "' . $escapedSlug . '"');
$url = $redirectResult->fetch_object()->url;
} else {
$url = DEFAULT_URL . $_SERVER['REQUEST_URI'];
}
$db->close();
}
}
}
}
header('Location: ' . $url, null, 301);
$attributeValue = htmlspecialchars($url);
?>
<meta http-equiv=refresh content="0;URL=<?php
echo $attributeValue;
?>
"><a href="<?php
echo $attributeValue;
?>
">Continue</a><script>location.href=<?php
echo json_encode($url, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES);
示例14: MySQLi
<?php
$conn1=new MySQLi("localhost","user","password","database");
if($conn1->connect_errno){
echo mysqli_connect_error();
exit;
}
$res=$conn1->query("show tables") or die($conn1->error);
while($tables=$res->fetch_array()){
$conn1->query("ALTER TABLE $tables[0] CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci") or die($conn1->error);
}
echo "The collation of your database has been successfully changed!";
$res->free();
$conn1->close();
?>
示例15: AddSet
private function AddSet()
{
if ($this->get_request_method() != "POST") {
$this->response('', 406);
}
$action = $this->_request['Action'];
$query = "";
$setName = $this->_request['Name'];
$setNumber = $this->_request['Number'];
$revision = $this->_request['Revision'];
$universal = $setNumber . "-" . $revision;
$pieces = $this->_request['Pieces'];
$theme = $this->_request['Theme'];
$subtheme = $this->_request['Subtheme'];
$wptag = $this->_request['Tag'];
$image = $this->_request['Image'];
$released = $this->_request['Start'];
$retired = $this->_request['End'];
$description = $this->_request['Description'];
$stub = $this->stubify($setName);
if ($released == '') {
$released = null;
}
if ($retired == '') {
$retired = null;
}
$mysqli = new MySQLi(self::DB_SERVER, self::DB_USER, self::DB_PASSWORD, self::DB);
if ($action == "new") {
// $query = $mysqli->prepare("INSERT into test_setguide_main
// set_number,revision,set_name,set_stub,theme_id,subtheme_id,pieces,
// root_image,date_released,date_retired,wordpress_tag)
// values(?,?,?,?,?,?,?,?,?,?,?)");
// $query->bind_param('iisssiiisiis',$number,$revision,$name,$stub,$theme,$subtheme,
// $pieces,$image,$released,$retired,$wptag);
$query = $mysqli->prepare("INSERT into test_setguide_main \r\n\t\t\t\t\t(set_number,set_name,theme_id,subtheme_id,pieces,root_image,revision,\r\n\t\t\t\t\tset_stub,date_released,date_retired,wordpress_tag,universal_id,`description`) \r\n\t\t\t\t\tvalues(?,?,?,?,?,?,?,?,?,?,?,?,?)");
$query->bind_param('isiiisisiisss', $setNumber, $setName, $theme, $subtheme, $pieces, $image, $revision, $stub, $released, $retired, $wptag, $universal, $description);
} else {
$query = $mysqli->prepare("UPDATE test_setguide_main SET \r\n\t\t\t\t\tset_name=?,theme_id=?,subtheme_id=?,pieces=?,\r\n\t\t\t\t\troot_image=?,revision=?,set_stub=?,date_released=?,date_retired=?,\r\n\t\t\t\t\twordpress_tag=?,universal_id=?,`description`=? \r\n\t\t\t\t\tWHERE set_number=" . $setNumber);
$query->bind_param('siiisisiisss', $setName, $theme, $subtheme, $pieces, $image, $revision, $stub, $released, $retired, $wptag, $universal, $description);
}
$query->execute();
$mysqli->close();
$this->response('', 200);
}