本文整理汇总了PHP中Connection::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::close方法的具体用法?PHP Connection::close怎么用?PHP Connection::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: finish
/**
* Finish the processor
* @param string $type finish type, supports: NORMAL, BROKEN, TIMEOUT
*/
public function finish($type = 'NORMAL')
{
$this->finished = true;
if ($type === 'BROKEN') {
$this->res->error = Connection::getLastError();
} else {
if ($type !== 'NORMAL') {
$this->res->error = ucfirst(strtolower($type));
}
}
// gzip decode
$encoding = $this->res->getHeader('content-encoding');
if ($encoding !== null && strstr($encoding, 'gzip')) {
$this->res->body = Client::gzdecode($this->res->body);
}
// parser
$this->res->timeCost = microtime(true) - $this->timeBegin;
$this->cli->runParser($this->res, $this->req, $this->key);
// conn
if ($this->conn) {
// close conn
$close = $this->res->getHeader('connection');
$this->conn->close($type !== 'NORMAL' || !strcasecmp($close, 'close'));
$this->conn = null;
// redirect
if (($this->res->status === 301 || $this->res->status === 302) && $this->res->numRedirected < $this->req->getMaxRedirect() && ($location = $this->res->getHeader('location')) !== null) {
Client::debug('redirect to \'', $location, '\'');
$req = $this->req;
if (!preg_match('/^https?:\\/\\//i', $location)) {
$pa = $req->getUrlParams();
$url = $pa['scheme'] . '://' . $pa['host'];
if (isset($pa['port'])) {
$url .= ':' . $pa['port'];
}
if (substr($location, 0, 1) == '/') {
$url .= $location;
} else {
$url .= substr($pa['path'], 0, strrpos($pa['path'], '/') + 1) . $location;
}
$location = $url;
/// FIXME: strip relative '../../'
}
// change new url
$prevUrl = $req->getUrl();
$req->setUrl($location);
if (!$req->getHeader('referer')) {
$req->setHeader('referer', $prevUrl);
}
if ($req->getMethod() !== 'HEAD') {
$req->setMethod('GET');
}
$req->clearCookie();
$req->setHeader('host', null);
$req->setHeader('x-server-ip', null);
// reset response
$this->res->numRedirected++;
$this->finished = $this->headerOk = false;
return $this->res->reset();
}
}
Client::debug('finished', $this->res->hasError() ? ' (' . $this->res->error . ')' : '');
$this->req = $this->cli = null;
}
示例2: tearDown
/**
* @return null
*/
public function tearDown()
{
$this->assertTrue($this->conn->close());
unset($this->conn);
unset($this->driver);
unset($this->stmtDriver);
unset($this->stmt);
}
示例3: login
function login()
{
$authorized = false;
$error = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (strlen($_POST['userid']) > 0) {
$validation = new Validation();
if ($message = $validation->userid($_POST['userid'], 'ユーザー名')) {
$error[] = $message;
} else {
$userid = $_POST['userid'];
}
$_POST['password'] = trim($_POST['password']);
if ($message = $validation->alphaNumeric($_POST['password'], 'パスワード')) {
$error[] = $message;
} else {
$password = md5($_POST['password']);
}
if (count($error) <= 0) {
$connection = new Connection();
$query = sprintf("SELECT id,userid,password,realname,user_group,authority FROM %suser WHERE userid = '%s'", DB_PREFIX, $connection->quote($userid));
$data = $connection->fetchOne($query);
$connection->close();
if (count($data) > 0 && $data['userid'] === $userid && $data['password'] === $password) {
$authorized = true;
} else {
$error[] = 'ユーザー名もしくはパスワードが<br />異なります。';
}
}
} else {
$error[] = 'ユーザー名を入力してください。';
}
} elseif (isset($_SESSION['status'])) {
if ($_SESSION['status'] == 'idle') {
$error[] = '自動的にログアウトしました。<br />ログインしなおしてください。';
} elseif ($_SESSION['status'] == 'expire') {
$error[] = 'ログインの有効期限が切れました。<br />ログインしなおしてください。';
}
session_unregister('status');
}
if ($authorized === true && count($error) <= 0) {
session_regenerate_id();
$_SESSION['logintime'] = time();
$_SESSION['accesstime'] = $_SESSION['logintime'];
$_SESSION['authorized'] = md5(__FILE__ . $_SESSION['logintime']);
$_SESSION['userid'] = $data['userid'];
$_SESSION['realname'] = $data['realname'];
$_SESSION['group'] = $data['user_group'];
$_SESSION['authority'] = $data['authority'];
if (isset($_SESSION['referer'])) {
header('Location: ' . $_SESSION['referer']);
session_unregister('referer');
} else {
header('Location: index.php');
}
exit;
} else {
return $error;
}
}
示例4: tryMethod
private function tryMethod($method, $args)
{
try {
return call_user_func_array([$this->connection, $method], $args);
} catch (\Exception $exception) {
$e = $exception;
while ($e->getPrevious() && !$e instanceof \PDOException) {
$e = $e->getPrevious();
}
if ($e instanceof \PDOException && $e->errorInfo[1] == self::MYSQL_CONNECTION_TIMED_WAIT_CODE) {
$this->connection->close();
$this->connection->connect();
$this->logger->notice('Connection to MySQL lost, reconnect okay.');
return call_user_func_array([$this->connection, $method], $args);
}
if (false !== strpos($exception->getMessage(), 'MySQL server has gone away') || false !== strpos($exception->getMessage(), 'Error while sending QUERY packet') || false !== strpos($exception->getMessage(), 'errno=32 Broken pipe')) {
$this->connection->close();
$this->connection->connect();
$this->logger->notice('Connection to MySQL lost, reconnect okay.');
return call_user_func_array([$this->connection, $method], $args);
}
$this->logger->critical('Connection to MySQL lost, unable to reconnect.', ['exception' => $exception]);
throw $e;
}
}
示例5: testConnectClose
/**
* @return null
*/
public function testConnectClose()
{
$this->assertTrue($this->conn->connect());
$this->assertEquals('connected', $this->conn->getStatus());
$this->assertTrue($this->conn->isConnected());
$this->assertFalse($this->conn->isError());
$this->assertTrue($this->conn->close());
$this->assertEquals('closed', $this->conn->getStatus());
$this->assertFalse($this->conn->isDriver());
$this->assertFalse($this->conn->isConnected());
$this->assertFalse($this->conn->isError());
/* lets see if we can connect again */
$this->assertFalse($this->conn->connect());
$this->assertEquals('closed', $this->conn->getStatus());
$this->assertFalse($this->conn->isConnected());
$this->assertTrue($this->conn->isError());
}
示例6: remove
public function remove($id_mensaje)
{
$db = new Connection();
$dateLeaving = date("m.d.y");
$query = "UPDATE MENSAJE SET fecha_baja = {$dateLeaving} where id_mensaje = {$id_mensaje}";
$results = $db->query($query) or die('Error dando de baja el mensaje: ' . mysqli_error($this->db));
$db->close();
}
示例7: handle
/**
* {@inheritdoc}
*/
public function handle(\Request $request)
{
$responseObject = new \Response();
self::$response = $responseObject;
self::$request = $request;
\DI::addInstance($responseObject);
\Route::map();
$connection = new \Connection(self::$request, self::$response);
return $connection->close();
}
示例8: modifyLimitAllWall
public function modifyLimitAllWall($limit)
{
$myConnection = new Connection();
//verifico que sea un número positivo
if (is_numeric($limit)) {
if ($limit >= 0) {
$myConnection->query("UPDATE MURO SET MURO.limite_muro = '{$limit}';");
}
} else {
header('location: ../../indexAdmin.php?malahi');
}
$myConnection->close();
header('location: ../../indexAdmin.php');
}
示例9: all
public static function all()
{
$aCategories = [];
$oCon = new Connection();
$sSQL = 'SELECT CategoryID FROM tbcategory WHERE Active=1';
$oResultSet = $oCon->query($sSQL);
while ($aRow = $oCon->fetchArray($oResultSet)) {
$iCategoryID = $aRow['CategoryID'];
$oCategory = new Category();
$oCategory->load($iCategoryID);
$aCategories[] = $oCategory;
}
$oCon->close();
return $aCategories;
}
示例10: all
public static function all()
{
$aGenres = array();
$oCon = new Connection();
$sSQL = "SELECT GenreID FROM tbgenres";
$oResultSet = $oCon->query($sSQL);
while ($aRow = $oCon->fetchArray($oResultSet)) {
$iGenreID = $aRow["GenreID"];
$oGenre = new Genre();
$oGenre->load($iGenreID);
$aGenres[] = $oGenre;
}
$oCon->close();
return $aGenres;
}
示例11: save
public function save()
{
$oCon = new Connection();
if ($this->iPostID == 0) {
$sSQL = "INSERT INTO tbposts (PostContent, TopicID, MemberID) VALUES (\n '" . $this->sPostContent . "',\n '" . $this->iTopicID . "',\n '" . $this->iMemberID . "')";
$bResult = $oCon->query($sSQL);
if ($bResult == true) {
$this->iPostID = $oCon->getInsertID();
} else {
die($sSQL . " did not run");
}
} else {
$sSQL = 'UPDATE tbposts SET Active = ' . $this->iActive . ' WHERE PostID=' . $this->iPostID;
$bResult = $oCon->query($sSQL);
}
$oCon->close();
}
示例12: selectAll
public function selectAll()
{
$resultArrayWithUsers = array();
$db = Connection::getConnection();
$rows = $db->query("SELECT * FROM `users`");
$count = 0;
while ($row = $rows->fetch(PDO::FETCH_ASSOC)) {
$user = new User();
$user->setLogin($row[User::$LOGIN]);
$user->setPassword($row[User::$PASSWORD]);
$user->setUserId($row[User::$USER_ID]);
$resultArrayWithUsers[$count] = $user;
$count++;
}
Connection::close();
return $resultArrayWithUsers;
}
示例13: load
public function load($iGenreID)
{
$oCon = new Connection();
$sSQL = "SELECT GenreID, GenreName, DisplayOrder \n\t\t\tFROM tbgenres \n\t\t\tWHERE GenreID = " . $iGenreID;
$oResultSet = $oCon->query($sSQL);
$aRow = $oCon->fetchArray($oResultSet);
$this->iGenreID = $aRow['GenreID'];
$this->sGenreName = $aRow['GenreName'];
$this->iDisplayOrder = $aRow['DisplayOrder'];
$sSQL = "SELECT RecordID\n\t\t\tFROM tbrecords \n\t\t\tWHERE GenreID = " . $iGenreID;
$oResultSet = $oCon->query($sSQL);
while ($aRow = $oCon->fetchArray($oResultSet)) {
$iRecordID = $aRow["RecordID"];
$oRecord = new Record();
$oRecord->load($iRecordID);
$this->aRecords[] = $oRecord;
}
$oCon->close();
}
示例14: save
public function save()
{
$oCon = new Connection();
if ($this->iMemberID == 0) {
$sSQL = "INSERT INTO tbmember\n (MemberName, MemberPassword, MemberEmail) VALUES ('" . $this->sMemberName . "',\n '" . $this->sMemberPassword . "',\n '" . $this->sMemberEmail . "')";
$bResult = $oCon->query($sSQL);
if ($bResult == true) {
$this->iMemberID = $oCon->getInsertID();
} else {
die($sSQL . " did not run");
}
} else {
$sSQL = "UPDATE tbmember SET MemberName = '" . $this->sMemberName . "'WHERE MemberID = " . $this->iMemberID;
$bResult = $oCon->query($sSQL);
if (bResult == false) {
die($sSQL . " did not run");
}
}
$oCon->close();
}
示例15: save
public function save()
{
$oCon = new Connection();
if ($this->iCategoryID == 0) {
$sSQL = 'INSERT INTO tbcategory (CategoryName, CategoryDesc)
VALUES(
"' . $this->sCategoryName . '",
"' . $this->sCategoryDesc . '")';
$bResult = $oCon->query($sSQL);
if ($bResult == true) {
$this->iCategoryID = $oCon->getInsertID();
} else {
die($sSQL . " did not run");
}
} else {
$sSQL = 'UPDATE tbcategory SET Active = ' . $this->iActive . ' WHERE CategoryID=' . $this->iCategoryID;
$bResult = $oCon->query($sSQL);
}
$oCon->close();
}