當前位置: 首頁>>代碼示例>>PHP>>正文


PHP resource::connect方法代碼示例

本文整理匯總了PHP中resource::connect方法的典型用法代碼示例。如果您正苦於以下問題:PHP resource::connect方法的具體用法?PHP resource::connect怎麽用?PHP resource::connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在resource的用法示例。


在下文中一共展示了resource::connect方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: endTest

 /**
  * Destroys the environment after each test method is run
  *
  * @return void
  * @access public
  */
 public function endTest()
 {
     $this->mongodb = new MongodbSource($this->_config);
     $this->mongodb->connect();
     $this->dropData();
     unset($this->mongodb);
 }
開發者ID:ThemisB,項目名稱:mongoDB-Datasource,代碼行數:13,代碼來源:first_mongodb_source.test.php

示例2: _open

 /**
  * Opens the memcache based session storage handler
  *
  * @access protected
  */
 protected function _open()
 {
     $this->_conn = new Memcache();
     if ($this->_conn->connect('localhost', 11211) !== true) {
         // fallback to the default PHP session storage mechanism
         session_module_name($this->_orig_module_name);
         return $this->start();
     }
     return true;
 }
開發者ID:heshuai64,項目名稱:gamestore,代碼行數:15,代碼來源:memcache.php

示例3: Memcache

 /**
  * Constructor
  *
  * @param string  $host      the memcached server host
  * @param int     $port      the memcached server port
  * @param int     $timeout   the default timeout
  *
  * @return void
  */
 function __construct($host = 'localhost', $port = 11211, $timeout = 3600)
 {
     $this->_host = $host;
     $this->_port = $port;
     $this->_timeout = $timeout;
     $this->_cache =& new Memcache();
     if (!$this->_cache->connect($this->_host, $this->_port)) {
         // dont use fatal here since we can go in an infinite loop
         echo 'Could not connect to Memcached server';
         exit;
     }
 }
開發者ID:bhirsch,項目名稱:voipdev,代碼行數:21,代碼來源:Memcache.php

示例4: connect

 /**
  * Attempt to connect to the SMTP server.
  *
  * @param int  $timeout    The timeout value (in seconds) for the
  *                         socket connection attempt.
  * @param bool $persistent Should a persistent socket connection
  *                         be used?
  *
  * @return mixed Returns a PEAR_Error with an error message on any
  *               kind of failure, or true on success.
  * @since 1.0
  */
 public function connect($timeout = null, $persistent = false)
 {
     $this->greeting = null;
     $result = $this->socket->connect($this->host, $this->port, $persistent, $timeout, $this->socket_options);
     if (PEAR::isError($result)) {
         return PEAR::raiseError('Failed to connect socket: ' . $result->getMessage());
     }
     /*
      * Now that we're connected, reset the socket's timeout value for
      * future I/O operations.  This allows us to have different socket
      * timeout values for the initial connection (our $timeout parameter)
      * and all other socket operations.
      */
     if ($this->timeout > 0) {
         if (PEAR::isError($error = $this->setTimeout($this->timeout))) {
             return $error;
         }
     }
     if (PEAR::isError($error = $this->parseResponse(220))) {
         return $error;
     }
     /* Extract and store a copy of the server's greeting string. */
     list(, $this->greeting) = $this->getResponse();
     if (PEAR::isError($error = $this->negotiate())) {
         return $error;
     }
     return true;
 }
開發者ID:alecpl,項目名稱:Net_SMTP,代碼行數:40,代碼來源:SMTP.php

示例5: update

 public function update()
 {
     if ($this->server->needReconnect and $this->connected) {
         $this->connected = false;
         $this->server->needReconnect = false;
     }
     if ($this->connected) {
         $err = socket_last_error($this->socket->getSocket());
         socket_clear_error($this->socket->getSocket());
         if ($err == 10057 or $err == 10054) {
             $this->server->getLogger()->error("Synapse connection has disconnected unexpectedly");
             $this->connected = false;
             $this->server->setConnected(false);
         } else {
             $data = @socket_read($this->socket->getSocket(), 65535, PHP_BINARY_READ);
             if ($data != "") {
                 $this->receiveBuffer .= $data;
             }
         }
     } else {
         if (($time = microtime(true)) - $this->lastCheck >= 3) {
             //re-connect
             $this->server->getLogger()->notice("Trying to re-connect to Synapse Server");
             if ($this->socket->connect()) {
                 $this->connected = true;
                 @socket_getpeername($this->socket->getSocket(), $address, $port);
                 $this->ip = $address;
                 $this->port = $port;
                 $this->server->setConnected(true);
                 $this->server->setNeedAuth(true);
             }
             $this->lastCheck = $time;
         }
     }
 }
開發者ID:iTXTech,項目名稱:Genisys,代碼行數:35,代碼來源:ServerConnection.php

示例6: __construct

 /**
  * Constructs a new ezcCacheMemcacheBackend object.
  *
  * For options for this backend see {@link ezcCacheStorageMemcacheOptions}.
  *
  * @throws ezcBaseExtensionNotFoundException
  *         If the PHP memcache and zlib extensions are not installed.
  * @throws ezcCacheMemcacheException
  *         If the connection to the Memcache host did not succeed.
  *
  * @param array(string=>mixed) $options
  */
 public function __construct(array $options = array())
 {
     if (!ezcBaseFeatures::hasExtensionSupport('memcache')) {
         throw new ezcBaseExtensionNotFoundException('memcache', null, "PHP does not have Memcache support.");
     }
     if (!ezcBaseFeatures::hasExtensionSupport('zlib')) {
         throw new ezcBaseExtensionNotFoundException('zlib', null, "PHP not configured with --with-zlib.");
     }
     $this->options = new ezcCacheStorageMemcacheOptions($options);
     $this->connectionIdentifier = $this->options->host . ':' . $this->options->port;
     if (!isset(self::$connections[$this->connectionIdentifier])) {
         self::$connections[$this->connectionIdentifier] = new Memcache();
         // Currently 0 backends use the connection
         self::$connectionCounter[$this->connectionIdentifier] = 0;
     }
     $this->memcache = self::$connections[$this->connectionIdentifier];
     // Now 1 backend uses it
     self::$connectionCounter[$this->connectionIdentifier]++;
     if ($this->options->persistent === true) {
         if (!@$this->memcache->pconnect($this->options->host, $this->options->port, $this->options->ttl)) {
             throw new ezcCacheMemcacheException('Could not connect to Memcache using a persistent connection.');
         }
     } else {
         if (!@$this->memcache->connect($this->options->host, $this->options->port, $this->options->ttl)) {
             throw new ezcCacheMemcacheException('Could not connect to Memcache.');
         }
     }
     $this->memcache->setCompressThreshold(self::COMPRESS_THRESHOLD);
 }
開發者ID:jacomyma,項目名稱:GEXF-Atlas,代碼行數:41,代碼來源:memcache_backend.php

示例7: connect

 /**
  * Connects to a database server
  *
  * @return bool - If the connection was successful.
  */
 public function connect()
 {
     if ($this->protocol) {
         return true;
     }
     $this->socket->connect();
     $this->protocol = new Protocol($this->socket);
     return true;
 }
開發者ID:taniele,項目名稱:mongofill,代碼行數:14,代碼來源:MongoClient.php

示例8: getRedis

 /**
  * 返回redis鏈接資源
  * @return unknown
  */
 function getRedis()
 {
     if (empty($this->redis) || !$this->redis->info()) {
         $this->redis = new \Redis();
         $redisConfig = \Config\Redis::getConfig();
         $res = $this->redis->connect($redisConfig['host'], $redisConfig['port']);
         if (empty($res)) {
             echo "connect Redis failed!\n";
         }
     }
     return $this->redis;
 }
開發者ID:hioop,項目名稱:statistics,代碼行數:16,代碼來源:Worker.php

示例9: connect

 /**
  * Attempt to connect to the SMTP server.
  *
  * @param   int     $timeout    The timeout value (in seconds) for the
  *                              socket connection.
  * @param   bool    $persistent Should a persistent socket connection
  *                              be used?
  *
  * @return mixed Returns a PEAR_Error with an error message on any
  *               kind of failure, or true on success.
  * @access public
  * @since  1.0
  */
 function connect($timeout = null, $persistent = false)
 {
     $result = $this->_socket->connect($this->host, $this->port, $persistent, $timeout);
     if (PEAR::isError($result)) {
         return new PEAR_Error('Failed to connect socket: ' . $result->getMessage());
     }
     if (PEAR::isError($error = $this->_parseResponse(220))) {
         return $error;
     }
     if (PEAR::isError($error = $this->_negotiate())) {
         return $error;
     }
     return true;
 }
開發者ID:bantudevelopment,項目名稱:polysmis,代碼行數:27,代碼來源:SMTP.php

示例10: cmdConnect

 /**
  * Attempt to connect to the IMAP server.
  *
  * @param string $host Hostname of the IMAP server
  * @param int    $port Port of the IMAP server (default = 143)
  *
  * @return mixed Returns a PEAR_Error with an error message on any
  *               kind of failure, or true on success.
  * @access public
  * @since  1.0
  */
 function cmdConnect($host = 'localhost', $port = 143)
 {
     if ($this->_connected) {
         return new PEAR_Error('already connected, logout first!');
     }
     if (PEAR::isError($error = $this->_socket->connect($host, $port, null, $this->_timeout, $this->_streamContextOptions))) {
         return $error;
     }
     if (PEAR::isError($this->_getRawResponse())) {
         return new PEAR_Error('unable to open socket');
     }
     $this->_connected = true;
     return true;
 }
開發者ID:abhinay100,項目名稱:fengoffice_app,代碼行數:25,代碼來源:IMAPProtocol.php

示例11: cmdConnect

 /**
  * Attempt to connect to the IMAP server.
  *
  * @return mixed Returns a PEAR_Error with an error message on any
  *               kind of failure, or true on success.
  * @access public
  * @since  1.0
  */
 function cmdConnect($host = "localhost", $port = 143)
 {
     if ($this->_connected) {
         return new PEAR_Error('already connected, logout first!');
     }
     if (PEAR::isError($this->_socket->connect($host, $port))) {
         return new PEAR_Error('unable to open socket');
     }
     if (PEAR::isError($this->_getRawResponse())) {
         return new PEAR_Error('unable to open socket');
     }
     $this->_connected = true;
     return true;
 }
開發者ID:BackupTheBerlios,項目名稱:phareon-svn,代碼行數:22,代碼來源:IMAPProtocol.php

示例12: startTest

 /**
  * Sets up the environment for each test method
  *
  * @return void
  * @access public
  */
 public function startTest()
 {
     $connections = ConnectionManager::enumConnectionObjects();
     if (!empty($connections['test']['classname']) && $connections['test']['classname'] === 'mongodbSource') {
         $config = new DATABASE_CONFIG();
         $this->_config = $config->test;
     }
     ConnectionManager::create('mongo_test', $this->_config);
     $this->Mongo = new MongodbSource($this->_config);
     $this->Post = ClassRegistry::init('Post');
     $this->Post->setDataSource('mongo_test');
     $this->mongodb =& ConnectionManager::getDataSource($this->Post->useDbConfig);
     $this->mongodb->connect();
     $this->dropData();
 }
開發者ID:ZachGambino-GG,項目名稱:cakephp-mongodb,代碼行數:21,代碼來源:mongodb_source.test.php

示例13: cmdConnect

 /**
  * Attempt to connect to the IMAP server.
  *
  * @return mixed Returns a PEAR_Error with an error message on any
  *               kind of failure, or true on success.
  * @access public
  * @since  1.0
  */
 function cmdConnect($host = "localhost", $port = 143)
 {
     if ($this->_connected) {
         return new PEAR_Error('already connected, logout first!');
     }
     $result = $this->_socket->connect($host, $port, false, 10);
     if (PEAR::isError($result)) {
         return PEAR::raiseError('Failed to connect socket: ' . $result->getMessage());
     }
     if (PEAR::isError($this->_getRawResponse())) {
         return new PEAR_Error('unable to open socket');
     }
     $this->_connected = true;
     return true;
 }
開發者ID:drognisep,項目名稱:Simple-Groupware,代碼行數:23,代碼來源:IMAPProtocol.php

示例14: connect

 /**
  * This function generates the FTP-connection
  *
  * @access  public
  * @param   string $host    (optional) The hostname
  * @param   int    $port    (optional) The port
  * @return  mixed           True on success, otherwise Jaws_Error
  */
 function connect($host = null, $port = null)
 {
     if (isset($host)) {
         $this->_host = $host;
     }
     if (isset($port)) {
         $this->_port = $port;
     }
     $this->_ftp->setHostname($this->_host);
     $this->_ftp->setPort($this->_port);
     $res = $this->_ftp->connect();
     if (PEAR::isError($res)) {
         return new Jaws_Error('Error while connecting to server ' . $this->_host . ' on ' . $this->_port . '.', __FUNCTION__);
     }
     return true;
 }
開發者ID:uda,項目名稱:jaws,代碼行數:24,代碼來源:FTP.php

示例15: connect

 /**
  * Attempt to connect to the SMTP server.
  *
  * @return mixed Returns a PEAR_Error with an error message on any
  *               kind of failure, or true on success.
  * @access public
  */
 function connect()
 {
     include_once 'Net/Socket.php';
     if (PEAR::isError($this->socket = new Net_Socket())) {
         return new PEAR_Error('unable to create a socket object');
     }
     if (PEAR::isError($this->socket->connect($this->host, $this->port))) {
         return new PEAR_Error('unable to open socket');
     }
     if (PEAR::isError($this->validateResponse('220'))) {
         return new PEAR_Error('smtp server not 220 ready');
     }
     if (!$this->identifySender()) {
         return new PEAR_Error('unable to identify smtp server');
     }
     return true;
 }
開發者ID:laiello,項目名稱:coopcrucial,代碼行數:24,代碼來源:SMTP.php


注:本文中的resource::connect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。