本文整理汇总了PHP中Connection::isConnected方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::isConnected方法的具体用法?PHP Connection::isConnected怎么用?PHP Connection::isConnected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::isConnected方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConnection
public function testConnection()
{
$this->subject->disconnect();
$result = $this->subject->connect();
$this->assertTrue($result);
// Try a reconnect
$result = $this->subject->connect();
$this->assertTrue($result);
$result = $this->subject->isConnected();
$this->assertTrue($result);
$result = $this->subject->disconnect();
$this->assertTrue($result);
$result = $this->subject->isConnected();
$this->assertFalse($result);
}
示例2: 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());
}
示例3: testIsConnected
public function testIsConnected()
{
$adapterConnection = $this->prophesize(AbstractConnection::class);
$adapterConnection->isConnected()->shouldBeCalled()->willReturn(true);
$connection = new Connection($adapterConnection->reveal());
$result = $connection->isConnected();
static::assertTrue($result);
}
示例4: setAktiv
public static function setAktiv(Connection $conn, $BrancheID, ErrorQueue $err)
{
if (!$conn->isConnected()) {
$err->addError("Keine Verbindung zur Datenbank.");
return false;
}
$neuerStatus = Branche::STATUS_AKTIV;
$q = new DBQuery("UPDATE branche SET Status='{$neuerStatus}' WHERE BrancheID='{$BrancheID}'");
if (!$conn->executeQuery($q)) {
$err->addError($conn->getLastError());
return false;
}
}
示例5: writepass
private function writepass(Connection $conn, $matrnr, $pass)
{
$pass = md5($pass);
$matrnr = intval($matrnr);
if ($conn->isConnected()) {
// Email des Studenten auslesen
$q = new DBQuery("SELECT Email FROM student WHERE MatrNr={$matrnr}");
if ($res = $conn->executeQuery($q)) {
if ($r = $res->getNextRow()) {
$email = $r[0];
} else {
$this->last_error = "Die Matrikelnummer existiert nicht.";
return false;
}
} else {
$this->last_error = "Die Matrikelnummer konnte nicht überprüft werden. " . $conn->getLastError();
return false;
}
// Das neue Passwort wird geschrieben
$q = new DBQuery("UPDATE student SET Pass='{$pass}' WHERE MatrNr={$matrnr}");
if ($res = $conn->executeQuery($q)) {
if ($res->affectedRows() > 0) {
return $email;
} else {
$this->last_error = "Die Matrikelnummer existiert nicht.";
return false;
}
} else {
$this->last_error = "Die Passwortänderung konnte nicht durchgeführt werden. " . $conn->getLastError();
return false;
}
} else {
$this->last_error = "Keine Verbindung zur Datenbank.";
return false;
}
}
示例6: testConnect
public function testConnect()
{
$this->object->connect();
$this->assertTrue($this->object->isConnected());
}
示例7: isConnected
/**
* @see Connection::isConnected()
*/
public function isConnected()
{
return $this->childConnection->isConnected();
}
示例8: runSet
/**
* Run a set of tasks
*
* @param Set $set A set of tasks to run
* @param int $timeout Time in seconds for the socket timeout. Max is 10 seconds
*
* @return void
* @see Net\Gearman\Set, Net\Gearman\Task
*/
public function runSet(Set $set, $timeout = null)
{
foreach ($this->getServers() as $server) {
$conn = Connection::connect($server, $timeout);
if (!Connection::isConnected($conn)) {
unset($this->servers[$server]);
continue;
}
$this->conn[] = $conn;
}
$totalTasks = $set->tasksCount;
$taskKeys = array_keys($set->tasks);
$t = 0;
if ($timeout !== null) {
$socket_timeout = min(10, (int) $timeout);
} else {
$socket_timeout = 10;
}
while (!$set->finished()) {
if ($timeout !== null) {
if (empty($start)) {
$start = microtime(true);
} else {
$now = microtime(true);
if ($now - $start >= $timeout) {
break;
}
}
}
if ($t < $totalTasks) {
$k = $taskKeys[$t];
$this->submitTask($set->tasks[$k]);
if ($set->tasks[$k]->type == Task::JOB_BACKGROUND || $set->tasks[$k]->type == Task::JOB_HIGH_BACKGROUND || $set->tasks[$k]->type == Task::JOB_LOW_BACKGROUND || $set->tasks[$k]->type == Task::JOB_EPOCH) {
$set->tasks[$k]->finished = true;
$set->tasksCount--;
}
$t++;
}
$write = null;
$except = null;
$read = $this->conn;
socket_select($read, $write, $except, $socket_timeout);
foreach ($read as $socket) {
$resp = Connection::read($socket);
if (count($resp)) {
$this->handleResponse($resp, $socket, $set);
}
}
}
}
示例9: setAktiv
public static function setAktiv(Connection $conn, $studiengangID, $aktiv, ErrorQueue $err)
{
if (!$conn->isConnected()) {
$err->addError("Keine Verbindung zur Datenbank.");
return false;
}
$neuerStatus = Studiengang::STATUS_AKTIV;
if ($aktiv == false) {
$neuerStatus = Studiengang::STATUS_INAKTIV;
}
$q = new DBQuery("UPDATE studiengang SET status='{$neuerStatus}' WHERE studiengangID='{$studiengangID}'");
if (!$conn->executeQuery($q)) {
$err->addError($conn->getLastError());
return false;
}
}
示例10: enumDozenten
public static function enumDozenten(Connection $conn)
{
$q = new DBQuery("SELECT d.PDozentID, d.Name, d.EMail, d.Telefon, log.Username FROM dozent d LEFT JOIN dozentlogin log ON (log.PDozentID=d.PDozentID) ORDER BY d.Name");
if ($conn->isConnected()) {
return $conn->executeQuery($q);
} else {
return false;
}
}
示例11: enumFreigaben
public static function enumFreigaben(Connection $conn, ErrorQueue $err)
{
$q = new DBQuery("SELECT FreigabeID, FreigabeBereich FROM freigabe ORDER BY FreigabeID");
if ($conn->isConnected()) {
if ($result = $conn->executeQuery($q)) {
return $result;
} else {
$err->addError("Datenbankfehler: " . $conn->getLastError());
}
} else {
return false;
}
}
示例12: isConnected
/**
* @see Connection::isConnected()
*/
public function isConnected()
{
return true;
krumo('DBArrayConnection isConnected ');
die;
return $this->childConnection->isConnected();
}
示例13: neuerStudentAnmelden
public static function neuerStudentAnmelden($matrnr, $name, $vorname, $email, $fhemail, ErrorQueue $err, Connection $conn)
{
$gen = new PassGenerator();
$pass = $gen->createNewPass(0);
$mdpass = md5($pass);
// Matrikelnummer überprüfen
$matrnr1 = $matrnr;
$matrnrlen = strlen($matrnr1);
$matrnr = intval($matrnr);
if ($matrnrlen != strlen($matrnr) || $matrnr <= 0) {
$err->addError("Die Matrikelnummer ist ungültig.");
return false;
}
$name = addslashes($name);
$email = addslashes($email);
$vorname = addslashes($vorname);
$fhemail .= "@stud.fh-luebeck.de";
$fhemail = addslashes($fhemail);
if (strcmp($name, "") == 0 || strcmp($vorname, "") == 0 || strcmp($email, "") == 0 || strcmp($fhemail, "") == 0) {
$err->addError("Bitte füll alle Felder aus.");
return false;
}
if (!Mailer::checkMail($email)) {
$err->addError("Die E-Mail-Adresse hat das falsche Format.");
return false;
}
if (!Mailer::checkMail($fhemail)) {
$err->addError("Die FHL-E-Mail-Adresse hat das falsche Format.");
return false;
}
if ($conn->isConnected()) {
$q = new DBQuery("INSERT INTO student(MatrNr, Name, EMail, Pass, Vorname) VALUES({$matrnr}, '{$name}', '{$email}', '{$mdpass}', '{$vorname}')");
if ($conn->executeQuery($q)) {
Mailer::mailit($fhemail, "Deine Anmeldung", "Hallo {$name},\n danke für Deine Anmeldung. Deine Login-Daten lauten:\n Passwort: \"{$pass}\"\nMatrikelnummer: {$matrnr}\n\n" . Studiengang::getSemsysInfo($conn, $err));
return true;
} else {
$err->addError("Die Anmeldung konnte nicht durchgeführt werden. Diese Matrikelnummer ist schon registriert.");
return false;
}
// Query executed
} else {
$err->addError("Keine Verbindung zur Datenbank.");
return false;
}
// Connected
}
示例14: enumGroessen
public static function enumGroessen(Connection $conn, ErrorQueue $err)
{
$q = new DBQuery("SELECT UnternehmensgroesseID, Mitarbeiterzahl, MindestName FROM unternehmensgroesse");
if ($conn->isConnected()) {
if ($result = $conn->executeQuery($q)) {
return $result;
} else {
$err->addError("Datenbankfehler: " . $conn->getLastError());
}
} else {
return false;
}
}