本文整理汇总了PHP中connection::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP connection::connect方法的具体用法?PHP connection::connect怎么用?PHP connection::connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类connection
的用法示例。
在下文中一共展示了connection::connect方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query
public function query()
{
//get connection object
$connection = new connection();
//get query object
$query = new query();
//get database connection
$pdo = $connection->connect();
//set database connection on query object
$query->setConnection($pdo);
return $query;
}
示例2: socket_server
public function socket_server($port)
{
global $sockets, $groups, $master;
$main = new Group();
$main->port = $port;
$main->name = "Main";
$main->members = array();
$main->task = "chat";
array_push($groups, $main);
$master = connection::WebSocket($port);
$sockets = array($master);
while (true) {
$changed = $sockets;
$write = NULL;
$except = NULL;
socket_select($changed, $write, $except, NULL);
foreach ($changed as $socket) {
if ($socket == $master) {
$client_socket = socket_accept($master);
if ($client_socket < 0) {
continue;
} else {
connection::connect($client_socket);
}
} else {
$client = select::bysocket($socket);
$bytes_lenght = socket_recv($socket, $buffer, 2048, 0);
if ($bytes_lenght <= 6) {
connection::disconnect($client);
} else {
if ($client->status < 2) {
connection::dohandshake($client, $buffer);
} else {
$buffer = other::handle_data($buffer);
if ($client->status < 3) {
connection::login($client, $buffer);
} else {
if (true) {
chat::process($client, $buffer);
} else {
//nothing
}
}
}
}
}
}
chat::logm("run\n");
}
}
示例3: connect
public function connect()
{
if ($this->host == null || $this->port == null) {
return false;
}
if (!is_object($this->socketClass)) {
return false;
}
if (!is_object($this->ircClass)) {
return false;
}
$conn = new connection($this->host, $this->port, CONNECT_TIMEOUT);
$conn->setSocketClass($this->socketClass);
$conn->setIrcClass($this->ircClass);
$conn->setCallbackClass($this);
$conn->setTimerClass($this->timerClass);
/* Set Timeouts */
$conn->setTransTimeout($this->transTimeout);
$conn->init();
if ($conn->getError()) {
$this->setError("Could not allocate socket");
return false;
}
$this->sockInt = $conn->getSockInt();
$conn->connect();
$this->connection = $conn;
return true;
}
示例4: connection
<?php
header('Content-Type: application/json; charset=utf-8');
require_once 'connection.php';
session_start();
if (isset($_SESSION['userid'])) {
$user = $_SESSION['userid'];
$connect = new connection();
$connect->connect();
$number = $connect->escapestring($_GET["number"]);
$sql = "SELECT `mailid`,`senderid`,`empfaengerid`,`text` FROM `mail` WHERE (`senderid` = " . $user . " OR `empfaengerid` = " . $user . ") order by `gesendet` LIMIT " . $number;
$connect->setsql($sql);
$row = $connect->getmap();
echo json_encode($row);
}
示例5: addFile
public function addFile($nick, $host, $port, $type, $filename, $size, $fromTimer = false)
{
$reverse = false;
if ($this->ircClass->getClientConf("mircdccreverse") != "" && $fromTimer == false && $type != DOWNLOAD) {
$port = intval($this->ircClass->getClientConf("mircdccreverse"));
if ($port == 0) {
return NULL;
}
$args = new argClass();
$args->arg1 = $nick;
$args->arg2 = $host;
$args->arg3 = $port;
$args->arg4 = $type;
$args->arg5 = $filename;
$args->arg6 = $size;
$args->arg7 = time();
$args->arg8 = FILE;
$this->ircClass->notice($nick, "DCC: NOTICE: This server is using the mIRC File Server Protocol. Please use ' /dccserver +s on " . $this->ircClass->getClientConf("mircdccreverse") . " ' to recieve files from me! Starting 6 second delay...", 0);
$this->ircClass->sendRaw("WHOIS " . $nick);
$this->timerClass->addTimer(irc::randomHash(), $this, "reverseTimer", $args, 6);
return;
}
if ($fromTimer == true) {
$reverse = DCC_REVERSE;
// using mIRC dcc reverse protocol
}
if ($host == NULL || $port == NULL) {
$conn = new connection(null, null, 0);
$listening = true;
$status = DCC_LISTENING;
} else {
$conn = new connection($host, $port, CONNECT_TIMEOUT);
$listening = false;
$status = DCC_CONNECTING;
}
$conn->setSocketClass($this->socketClass);
$conn->setIrcClass($this->ircClass);
$conn->setCallbackClass($this);
$conn->setTransTimeout(30);
$conn->setTimerClass($this->timerClass);
$port = $conn->init();
if ($conn->getError()) {
$this->ircClass->log("File transfer start error: " . $conn->getErrorMsg());
return false;
}
$sockInt = $conn->getSockInt();
$id = $this->highestId();
$file = new file($id, $nick, $sockInt, $host, $port, $type, $reverse);
if ($file->transferType == UPLOAD) {
$this->fileUlCount++;
} else {
$this->fileDlCount++;
}
$file->setIrcClass($this->ircClass);
$file->setDccClass($this);
$file->setSocketClass($this->socketClass);
$file->setProcQueue($this->procQueue);
$file->setTimerClass($this->timerClass);
$file->connection = $conn;
$file->status = $status;
$file->removed = false;
$this->dccList[$sockInt] = $file;
$file->initialize($filename, $size);
$conn->setCallbackClass($file);
if ($listening == true) {
$this->timerClass->addTimer(irc::randomHash(), $this, "checkDccTimeout", $file, 30, true);
}
if ($reverse == true) {
$conn->connect();
}
return $port;
}
示例6: connection
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
$project = "PDO|WebDevActivity";
require_once 'header.php';
require_once './connection.php';
$conn = new connection('guest_book', 'root', '1');
$pdo = $conn->connect();
//check isset add
$data = [];
if (isset($_POST['update'])) {
require_once './connection.php';
// database connection
$conn = new connection('guest_book', 'root', '1');
$conn = $conn->connect();
$data['Name'] = htmlspecialchars($_POST['Name']);
$data['Email'] = htmlspecialchars($_POST['Email']);
$data['url'] = htmlspecialchars($_POST['url']);
$data['title'] = htmlspecialchars($_POST['title']);
$data['comment'] = htmlspecialchars($_POST['comment']);
$data['img'] = htmlspecialchars($_POST['img']);
// query
$sql = "UPDATE posts SET name=?, email=?,url=?,title=?,comment=?,img=? WHERE id=?";
$q = $conn->prepare($sql);
$q->execute(array($data['Name'], $data['Email'], $data['url'], $data['title'], $data['comment'], $data['img'], $_GET['id']));
//redirect to index.php
header('Location: ' . 'index.php');
}
?>
示例7: reconnect
public function reconnect()
{
$this->updateContext();
try {
$this->connectStartTime = time();
$conn = new connection($this->getClientConf('server'), $this->getClientConf('port'), CONNECT_TIMEOUT);
$this->conn = $conn;
$conn->setSocketClass($this->socketClass);
$conn->setIrcClass($this);
$conn->setCallbackClass($this);
$conn->setTimerClass($this->timerClass);
$conn->init();
if ($conn->getError()) {
throw new ConnectException($conn->getErrorMsg());
}
//Bind socket...
if ($this->getClientConf('bind') != "") {
$conn->bind($this->getClientConf('bind'));
}
$this->sockInt = $conn->getSockInt();
$conn->connect();
} catch (ConnectException $e) {
$this->beginReconnectTimer();
$this->status = STATUS_ERROR;
$this->exception = $e;
return;
}
$this->status = STATUS_CONNECTING;
$this->updateContext();
return;
}
示例8: connection
<?php
include 'config.php';
$connection = new connection();
$connection->connect("localhost", "root", "", "login_db");
示例9: query
if (!$this->link) {
echo "Not Connected To Database";
} else {
//echo "Connected Successfully!!!!!";
}
if (!mysql_select_db($this->db_name, $this->link)) {
echo "Database Not Selected";
} else {
//echo "Database Selected Successfully";
}
}
public function query($sql)
{
return mysql_query($sql);
}
public function num_rows($result)
{
return mysql_num_rows($result);
}
public function fetch($result)
{
return mysql_fetch_array($result);
}
public function fetchassoc($result)
{
return mysql_fetch_assoc($result);
}
}
$object = new connection();
$object->connect('localhost', 'root', '', 'manage_website');