Destroys an existing PDO connection

@return bool Returns true if the connection existed and was destroyed; returns false otherwise
541583
public function disconnect()
    {
        if ($this->pdo instanceof \PDO) {
            $this->pdo = null;

            $disconnected = true;
        } else {
            $disconnected = false;
        }

        return $disconnected;
    }
263189
function doDelete(PDO $conn = null) {
		$q = clone $this;

		if (!$q->getTable()) {
			throw new RuntimeException('No table specified.');
		}

		$q->setAction(self::ACTION_DELETE);
		return (int) $q->getQuery($conn)->bindAndExecute()->rowCount();
	}
1013525
public function Connection() {
      $this->_IsPersistent = GetValue(PDO::ATTR_PERSISTENT, $this->ConnectionOptions, FALSE);
      if(!is_object($this->_Connection)) {
         try {
            $this->_Connection = new PDO(strtolower($this->Engine) . ':' . $this->Dsn, $this->User, $this->Password, $this->ConnectionOptions);
            $this->_Connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
            
            if($this->ConnectionOptions[1002])
               $this->Query($this->ConnectionOptions[1002]);
            
            // We only throw exceptions during connect
            $this->_Connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
         } catch (Exception $ex) {
            $Timeout = FALSE;
            if ($ex->getCode() == '2002' && preg_match('/Operation timed out/i', $ex->getMessage()))
               $Timeout = TRUE;
            if ($ex->getCode() == '2003' && preg_match("/Can't connect to MySQL/i", $ex->getMessage()))
               $Timeout = TRUE;
                    
            if ($Timeout)
               throw new Exception(ErrorMessage('Timeout while connecting to the database', $this->ClassName, 'Connection', $ex->getMessage()), 504);
            
            trigger_error(ErrorMessage('An error occurred while attempting to connect to the database', $this->ClassName, 'Connection', $ex->getMessage()), E_USER_ERROR);
         }
      }
      
      return $this->_Connection;
   }
940269
public function connect()
    {
        if ($this->isConnected) {
            return false;
        }

        if (!$this->pdo) {
            $this->beforeConnect && call_user_func($this->beforeConnect, $this);

            $dsn = $this->getDsn();
            $attrs = $this->attrs + array(
                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                PDO::ATTR_STRINGIFY_FETCHES => true,
                PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
            );

            try {
                $this->pdo = new PDO($dsn, $this->user, $this->password, $attrs);
            } catch (\PDOException $e) {
                $this->connectFails && call_user_func($this->connectFails, $this, $e);
                throw $e;
            }

            $this->afterConnect && call_user_func($this->afterConnect, $this, $this->pdo);
        }

        $this->isConnected = true;

        return true;
    }
606451
public function destroy()
    {
        // Avoid repeated calls.
        if ($this->_status === self::STATUS_CLOSED) {
            return;
        }
        // Remove event listener.
        Worker::$globalEvent->del($this->_socket, EventInterface::EV_READ);
        Worker::$globalEvent->del($this->_socket, EventInterface::EV_WRITE);

        // Close socket.
        set_error_handler(function(){});
        fclose($this->_socket);
        restore_error_handler();

        $this->_status = self::STATUS_CLOSED;
        // Try to emit onClose callback.
        if ($this->onClose) {
            try {
                call_user_func($this->onClose, $this);
            } catch (\Exception $e) {
                Worker::log($e);
                exit(250);
            } catch (\Error $e) {
                Worker::log($e);
                exit(250);
            }
        }
        // Try to emit protocol::onClose
        if ($this->protocol && method_exists($this->protocol, 'onClose')) {
            try {
                call_user_func(array($this->protocol, 'onClose'), $this);
            } catch (\Exception $e) {
                Worker::log($e);
                exit(250);
            } catch (\Error $e) {
                Worker::log($e);
                exit(250);
            }
        }
        $this->_sendBuffer = $this->_recvBuffer = '';
        if ($this->_status === self::STATUS_CLOSED) {
            // Cleaning up the callback to avoid memory leaks.
            $this->onMessage = $this->onClose = $this->onError = $this->onBufferFull = $this->onBufferDrain = null;
            // Remove from worker->connections.
            if ($this->worker) {
                unset($this->worker->connections[$this->_id]);
            }
            unset(static::$connections[$this->_id]);
        }
    }
788448
public function clearExpiredPDO()
    {
        if ($this->Using !== 'PDO') {
            return false;
        }
        $PDO = $this->WorkingData->prepare(self::clearExpiredQuery);
        if ($PDO !== false && $PDO->execute(['time' => time()])) {
            return ($PDO->rowCount() > 0);
        }
        return false;
    }
1269130
public function destroy(): bool
    {
        if (! $this->isStarted()) {
            $this->start();
        }
        $name = $this->getName();
        $params = $this->getCookieParams();
        $this->clear();
        $destroyed = session_destroy();
        if ($destroyed) {
            call_user_func($this->delete_cookie, $name, $params);
        }

        return $destroyed;
    }
27406
public function disconnect()
    {
        if (!is_resource($this->fp)) {
            return $this->raiseError('not connected');
        }

        @fclose($this->fp);
        $this->fp = null;

        return true;
    }
525697
public function destroy(string $id) : bool
    {
        static $stmt;
        if (!isset($stmt)) {
            $stmt = $this->pdo->prepare("DELETE FROM cesession_session WHERE id = :id");
        }
        $stmt->execute(compact('id'));
        return ($affectedRows = $stmt->rowCount()) && $affectedRows;
    }
33618
public function destroy()
	{
		$data = $this->toArray();

		// Trigger the onUserBeforeDelete event
		Event::trigger('user.onUserBeforeDelete', array($data));

		// Remove associated data
		if ($this->reputation->get('id'))
		{
			if (!$this->reputation->destroy())
			{
				$this->addError($this->reputation->getError());
				return false;
			}
		}

		foreach ($this->tokens()->rows() as $token)
		{
			if (!$token->destroy())
			{
				$this->addError($token->getError());
				return false;
			}
		}

		Map::destroyByUser($this->get('id'));

		// Attempt to delete the record
		$result = parent::destroy();

		if ($result)
		{
			// Trigger the onUserAfterDelete event
			Event::trigger('user.onUserAfterDelete', array($data, true, $this->getError()));
		}

		return $result;
	}
124731
public function terminate()
    {

        if( $this->isTerminated() ) {
            return true;
        }

        // remove from the instances array (ie, we no longer wish to maintain or keep this connection up)
        if( false === $key = array_search( $this, self::$instances, true ) ) {
            throw new \LogicException( "Trying to terminate a connection that isn't in instances store. This is a problem - talk to Pete." );
        }
        unset( self::$instances[$key] );

        // remove from its creating connection factory if it exists there
        if( $this->connectionFactory ) {
            $this->connectionFactory->remove($this);
        }

        try {
            $output = pg_close( $this->resource );
        } catch ( \Exception $e ) {
            $output = false;
        }

        // mark the resource a terminated
        $this->terminated = array(
            'time' => time(),
//            'backtrace' => sane_debug_backtrace(),
        );

        return $output;

    }
1202471
public function destroy($id)
    {
        try {
            return (bool) $this->db->from($this->table)
                    ->where($this->columns['id'])->eq($id)
                    ->delete();
        } catch (PDOException $e) {
            return false;
        }
    }
603226
public function disconnect()
    {
        if (false === $this->connected) {
            return true;
        }

        if ($this->socket) {
            $this->send(WebsocketPayload::generateClosePayload(), WebsocketPayload::OPCODE_CLOSE);
            $this->closing = true;

            $payloadLength = ord(fread($this->socket, 1));
            $payload = fread($this->socket, $payloadLength);

            if ($this->closing) {
                $this->closing = false;
            } else {
                if ($payloadLength >= 2) {
                    $bin = $payload[0] . $payload[1];
                    $status = bindec(sprintf('%08b%08b', ord($payload[0]), ord($payload[1])));

                    $this->send($bin . 'Close acknowledged: ' . $status, WebsocketPayload::OPCODE_CLOSE);
                }
            }

            fclose($this->socket);
            $this->connected = false;

            return true;
        }

        return false;
    }
409200
public function destroy($id)
    {
        $this->newQuery();

        $queryKey = $this->queryBuilder->whereEqual($this->primaryFieldName, $id)->firstQueryKey();

        if (!$this->isCompleteKey($queryKey)) {
            return false;
        }

        return (bool)$this->redClient->del([$queryKey]);
    }
292334
public function close_connection()
    {
        $this->last_error = null;
        $this->last_error_id = null;
        $this->last_query = null;
        $this->prepared_query = null;
        $this->row = null;
        $this->field_names = null;
        
        if ($this->mysqli) {
            @$this->mysqli->close();
        }
        
        if ($this->statement) {
            @$this->statement->close();
        }
        
        $this->mysqli = null;
        $this->mysqli_result = null;
        $this->statement = null;
        $this->last_error = null;
        $this->last_error_id = null;
        
        return true;
    }
1256455
public function delete()
    {
        if ($this->deleteStatement == null) {
            $this->deleteStatement = $this->connection->prepare("DELETE FROM User WHERE username = ?");
            $this->deleteStatement->bindParam(1, $this->username);
        }
        try{
            $this->deleteStatement->execute();
        } catch (PDOException $exception){
            return false;
        }
        if ($this->exists()) {
            return false;
        }
        $this->notifyObservers(User::EVENT_DELETE);
        return true;
    }
51321
public function disconnect() {
        if ($this->isConnected()) {
            $tmp = $this->hConnection;
            $this->hConnection = null;
            pg_close($tmp);
        }
        return $this;

        // TODO: If there are open large object resources on the connection, do not close the connection before closing all
        //       large object resources.
        // @see  http://php.net/manual/en/function.pg-close.php
    }