当前位置: 首页>>代码示例>>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;未经允许,请勿转载。