当前位置: 首页>>代码示例>>PHP>>正文


PHP object::connect方法代码示例

本文整理汇总了PHP中object::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP object::connect方法的具体用法?PHP object::connect怎么用?PHP object::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在object的用法示例。


在下文中一共展示了object::connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Loads and initiates the SQL driver that we need to use.
  *
  */
 public function __construct()
 {
     if (!$this->_oObject) {
         switch (Phpfox::getParam(array('db', 'driver'))) {
             case 'mysqli':
                 $sDriver = 'phpfox.database.driver.mysqli';
                 break;
             case 'postgres':
                 $sDriver = 'phpfox.database.driver.postgres';
                 break;
             case 'mssql':
                 $sDriver = 'phpfox.database.driver.mssql';
                 break;
             case 'oracle':
                 $sDriver = 'phpfox.database.driver.oracle';
                 break;
             case 'sqlite':
                 $sDriver = 'phpfox.database.driver.sqlite';
                 break;
             default:
                 $sDriver = 'phpfox.database.driver.mysql';
                 break;
         }
         $this->_oObject = Phpfox::getLib($sDriver);
         $this->_oObject->connect(Phpfox::getParam(array('db', 'host')), Phpfox::getParam(array('db', 'user')), Phpfox::getParam(array('db', 'pass')), Phpfox::getParam(array('db', 'name')));
     }
 }
开发者ID:Lovinity,项目名称:EQM,代码行数:31,代码来源:database.class.php

示例2: __invoke

 /**
  * Invoke middleware
  * 
  * @param ServerRequestInterface $request  request
  * @param ResponseInterface      $response response
  * @param callable               $next     callable
  * 
  * @return object ResponseInterface
  */
 public function __invoke(Request $request, Response $response, callable $next = null)
 {
     $this->websocket = new Websocket($this->getContainer()->get('app'), $this->getContainer()->get('config'), $this->getContainer()->get('logger.params'));
     $this->websocket->connect();
     $err = null;
     return $next($request, $response, $err);
 }
开发者ID:obullo,项目名称:http-middlewares,代码行数:16,代码来源:Debugger.php

示例3: __construct

 /**
  * 初始化
  * 
  * @param array $option  配置数组
  */
 public function __construct($option)
 {
     empty($option['host']) or $this->host = $option['host'];
     empty($option['port']) or $this->port = intval($option['port']);
     is_null($option['flag']) or $this->flag = $option['flag'];
     is_null($option['expire']) or $this->expire = intval($option['expire']);
     $this->mem = new Memcache();
     $this->mem->connect($this->host, $this->port) and $this->isConnected = TRUE;
 }
开发者ID:RenzcPHP,项目名称:3dproduct,代码行数:14,代码来源:mem.php

示例4: __construct

 /**
  * 初始化Redis
  * 
  * @param array $config
  */
 public function __construct($config = array())
 {
     if (empty($config['server'])) {
         $config['server'] = '127.0.0.1';
     }
     if (empty($config['port'])) {
         $config['port'] = '6379';
     }
     $this->redis = new Redis();
     $this->redis->connect($config['server'], $config['port']);
 }
开发者ID:Rgss,项目名称:imp,代码行数:16,代码来源:Redis.php

示例5: connect

 /**
  * Connect to the queue.
  *
  * @return .
  */
 public function connect()
 {
     $config =& $this->_config;
     if (!$this->connection) {
         $this->connection = new AMQPConnection(array('host' => $config['host'], 'port' => $config['port'], 'vhost' => $config['vhost'], 'login' => $config['login'], 'password' => $config['password'], 'read_timeout' => $config['readTimeout'], 'write_timeout' => $config['writeTimeout'], 'connect_timeout' => $config['connectTimeout']));
         if ($this->connection->connect()) {
             $this->_isConnected = true;
         }
     }
     return $this->isConnected();
 }
开发者ID:unionofrad,项目名称:li3_queue,代码行数:16,代码来源:AMQP.php

示例6: _connect

 protected function _connect()
 {
     $this->_iSession = new iSession();
     if (!isset($this->profile['port'])) {
         $this->profile['port'] = 8088;
     }
     $connectionArray = array('host' => $this->profile['host'], 'port' => $this->profile['port'], 'read_only' => 1, 'charset' => in_UTF8, 'database' => $this->profile['database'], 'user' => $this->profile['user'], 'password' => $this->profile['password'], 'page_size' => 20, 'max_answers_count' => 1000, 'default-language' => 'en');
     $cnx = @$this->_iSession->connect($connectionArray);
     if ($cnx) {
         return $this->_iSession;
     } else {
         throw new Exception($this->_iSession->status());
     }
 }
开发者ID:hadrienl,项目名称:jelix,代码行数:14,代码来源:intuition.dbconnection.php

示例7: __construct

 /**
  * Initialize
  */
 public function __construct()
 {
     // ObjectManager aufrufen
     $this->objectManager = ObjectManager::getInstance();
     // Registry
     $this->registry = $this->objectManager->getObject('Registry');
     // Request
     $this->request = $this->objectManager->getObject('Request');
     // Debug Trace
     $this->debug = $this->objectManager->getObject('Debug');
     // Database access point
     $this->database = $this->objectManager->getObject('Database');
     $this->database->connect();
     return $this;
 }
开发者ID:DevSKolb,项目名称:FLOWLite,代码行数:18,代码来源:MainController.php

示例8: connect

 /**
  * Handles connecting to the server and checking the
  * response is valid.
  *
  * @access private
  * @param  string $host Hostname of server
  * @param  string $port Port of server
  * @return mixed        True on success, PEAR_Error otherwise
  */
 function connect($host, $port)
 {
     if (NET_SIEVE_STATE_DISCONNECTED != $this->_state) {
         $msg = 'Not currently in DISCONNECTED state';
         $code = 1;
         return $this->_raiseError($msg, $code);
     }
     if (PEAR::isError($res = $this->_sock->connect($host, $port, null, 5))) {
         return $res;
     }
     $this->_state = NET_SIEVE_STATE_AUTHORISATION;
     if (PEAR::isError($res = $this->_doCmd())) {
         return $res;
     }
     /*
             if(PEAR::isError($res = $this->_cmdCapability() )) {
                 $msg='Failed to connect, server said: ' . $res->getMessage();
                 $code=2;
                 return $this->_raiseError($msg,$code);
             }
     */
     // Get logon greeting/capability and parse
     $this->_parseCapability($res);
     return true;
 }
开发者ID:GeekyNinja,项目名称:LifesavingCAD,代码行数:34,代码来源:Sieve.php

示例9: Connect

		/**
		 * Connect to memcached server
		 * @return bool
		 * @access protected
		 */
		protected function Connect()
		{
			if (!is_object($this->MemCache))
				$this->MemCache = new Memcache;
				
			try
			{
				$this->IsConnected = @$this->MemCache->connect($this->Options["host"], $this->Options["port"]);
				return $this->IsConnected;
			}
			catch (Exception $e)
			{
				Core::RaiseWarning("Cannot connect to memcached server on 
				".$this->Options["host"] .":". $this->Options["port"]);
				
				return false;
			}
			
			// Would need it anyway
			if (!$retval)
				Core::RaiseWarning("Cannot connect to memcached server on 
				".$this->Options["host"] .":". $this->Options["port"]);
			
			return false;
		}
开发者ID:rchicoria,项目名称:epp-drs,代码行数:30,代码来源:class.MemcacheCacheDriver.php

示例10: list

 /**
  * Connect to the SMTP server by instantiating a Net_SMTP object.
  *
  * @return mixed Returns a reference to the Net_SMTP object on success, or
  *               a PEAR_Error containing a descriptive error message on
  *               failure.
  *
  * @since  1.2.0
  * @access public
  */
 function &getSMTPObject()
 {
     if (is_object($this->_smtp) !== false) {
         return $this->_smtp;
     }
     include_once 'Net/SMTP.php';
     $this->_smtp =& new Net_SMTP($this->host, $this->port, $this->localhost, false, 0, $this->socket_options);
     /* If we still don't have an SMTP object at this point, fail. */
     if (is_object($this->_smtp) === false) {
         return $this->raiseError('Failed to create a Net_SMTP object', PEAR_MAIL_SMTP_ERROR_CREATE);
     }
     /* Configure the SMTP connection. */
     if ($this->debug) {
         $this->_smtp->setDebug(true, $this->debug_handler);
     }
     /* Attempt to connect to the configured SMTP server. */
     if (PEAR::isError($res = $this->_smtp->connect($this->timeout))) {
         list($code, $error) = $this->_error('Failed to connect to ' . $this->host . ':' . $this->port, $res);
         $txt = implode("\n", $this->_smtp->_arguments);
         return $this->raiseError($error, PEAR_MAIL_SMTP_ERROR_CONNECT, null, null, array('smtpcode' => $code, 'smtptext' => $txt));
     }
     /* Attempt to authenticate if authentication has been enabled. */
     if ($this->auth) {
         $method = is_string($this->auth) ? $this->auth : '';
         if (PEAR::isError($res = $this->_smtp->auth($this->username, $this->password, $method))) {
             list($code, $error) = $this->_error("{$method} authentication failure", $res);
             $txt = implode("\n", $this->_smtp->_arguments);
             $this->_smtp->rset();
             return $p = new PEAR();
             raiseError($error, PEAR_MAIL_SMTP_ERROR_AUTH, null, null, array('smtpcode' => $code, 'smtptext' => $txt));
         }
     }
     return $this->_smtp;
 }
开发者ID:roojs,项目名称:pear,代码行数:44,代码来源:smtp.php

示例11: smtpmail

 /**
  * Envoi via la classe smtp
  * 
  * @param string $address  Adresses des destinataires
  * @param string $message  Corps de l'email
  * @param string $headers  Entêtes de l'email
  * @param string $Rpath    Adresse d'envoi (définit le return-path)
  * 
  * @access private
  * @return boolean
  */
 function smtpmail($address, $message, $headers, $Rpath)
 {
     if (!is_resource($this->smtp->connect_id) || !$this->smtp->noop()) {
         if (!$this->smtp->connect()) {
             $this->error($this->smtp->msg_error);
             return false;
         }
     }
     if (!$this->smtp->mail_from($Rpath)) {
         $this->error($this->smtp->msg_error);
         return false;
     }
     foreach ($address as $email) {
         if (!$this->smtp->rcpt_to($email)) {
             $this->error($this->smtp->msg_error);
             return false;
         }
     }
     if (!$this->smtp->send($headers, $message)) {
         $this->error($this->smtp->msg_error);
         return false;
     }
     //
     // Apparamment, les commandes ne sont réellement effectuées qu'après la fermeture proprement
     // de la connexion au serveur SMTP. On quitte donc la connexion courante si l'option de connexion
     // persistante n'est pas activée.
     //
     if (!$this->persistent_connection) {
         $this->smtp->quit();
     }
     return true;
 }
开发者ID:bibwho,项目名称:MATPbootstrap,代码行数:43,代码来源:class.mailer.php

示例12:

 /**
  * Connect to the SMTP server by instantiating a Net_SMTP object.
  *
  * @return mixed Returns a reference to the Net_SMTP object on success, or
  *               a PEAR_Error containing a descriptive error message on
  *               failure.
  *
  * @since  1.2.0
  * @access public
  */
 function &getSMTPObject()
 {
     if (is_object($this->_smtp) !== false) {
         return $this->_smtp;
     }
     include_once 'Net/SMTP.php';
     $this->_smtp = new Net_SMTP($this->host, $this->port, $this->localhost);
     /* If we still don't have an SMTP object at this point, fail. */
     if (is_object($this->_smtp) === false) {
         return PEAR::raiseError('Failed to create a Net_SMTP object', PEAR_MAIL_SMTP_ERROR_CREATE);
     }
     /* Configure the SMTP connection. */
     if ($this->debug) {
         $this->_smtp->setDebug(true);
     }
     /* Attempt to connect to the configured SMTP server. */
     if (PEAR::isError($res = $this->_smtp->connect($this->timeout))) {
         $error = $this->_error('Failed to connect to ' . $this->host . ':' . $this->port, $res);
         return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_CONNECT);
     }
     /* Attempt to authenticate if authentication has been enabled. */
     if ($this->auth) {
         $method = is_string($this->auth) ? $this->auth : '';
         if (PEAR::isError($res = $this->_smtp->auth($this->username, $this->password, $method))) {
             $error = $this->_error("{$method} authentication failure", $res);
             $this->_smtp->rset();
             return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_AUTH);
         }
     }
     return $this->_smtp;
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:41,代码来源:smtp.php

示例13: connect

 /**
  * Handles connecting to the server and checking the
  * response is valid.
  *
  * @access private
  * @param  string $host Hostname of server
  * @param  string $port Port of server
  * @param  array  $options List of options to pass to connect
  * @param  boolean $useTLS Use TLS if available
  * @return mixed        True on success, PEAR_Error otherwise
  */
 function connect($host, $port, $options = null, $useTLS = true)
 {
     if (NET_SIEVE_STATE_DISCONNECTED != $this->_state) {
         $msg = 'Not currently in DISCONNECTED state';
         $code = 1;
         return $this->_raiseError($msg, $code);
     }
     if (PEAR::isError($res = $this->_sock->connect($host, $port, false, 5, $options))) {
         return $res;
     }
     if ($this->_bypassAuth === false) {
         $this->_state = NET_SIEVE_STATE_AUTHORISATION;
         if (PEAR::isError($res = $this->_doCmd())) {
             return $res;
         }
     } else {
         $this->_state = NET_SIEVE_STATE_TRANSACTION;
     }
     // Explicitly ask for the capabilities in case the connection
     // is picked up from an existing connection.
     if (PEAR::isError($res = $this->_cmdCapability())) {
         $msg = 'Failed to connect, server said: ' . $res->getMessage();
         $code = 2;
         return $this->_raiseError($msg, $code);
     }
     if ($useTLS === true) {
         // check if we can enable TLS via STARTTLS
         if (isset($this->_capability['starttls']) && function_exists('stream_socket_enable_crypto') === true) {
             if (PEAR::isError($res = $this->_startTLS())) {
                 return $res;
             }
         }
     }
     return true;
 }
开发者ID:ehmedov,项目名称:www,代码行数:46,代码来源:Sieve.php

示例14: getInstance

 /**
  * 获取Redis实例
  * @param string $host
  * @param string $port
  * @param string $auth
  * @param string $sign
  */
 public static function getInstance($host = 'localhost', $port = '6379', $auth = '', $sign = 'default')
 {
     if (!self::$instance) {
         self::$instance = new Redis();
         self::$instance->connect($host, $port);
         if ($auth) {
             self::$instance->auth($auth);
         }
         self::$instanceList[$sign] = self::$instance;
     } else {
         if (isset(self::$instanceList[$sign])) {
             self::$instance = self::$instanceList[$sign];
         }
     }
     return self::$instance;
 }
开发者ID:noikiy,项目名称:dophin,代码行数:23,代码来源:CacheRedis.class.php

示例15: __construct

 /**
  * 构造函数
  *
  * @access public
  *
  * @param array $params 数据库连接参数,如主机名,数据库用户名,密码等
  *
  * @return boolean
  */
 public function __construct($options = null)
 {
     if (!extension_loaded('redis')) {
         Controller::halt('The redis extension to be loaded!');
     }
     //当参数为空时,程序则自动加载配置文件中数据库连接参数
     if (!$options || !is_array($options)) {
         $options = Configure::get('redis');
         if (!$options) {
             $options = array();
         }
     }
     $options += $this->_defaultServer;
     //连接数据库
     $this->_dbLink = new Redis();
     $this->_dbLink->connect($options['host'], $options['port']);
     return true;
 }
开发者ID:a53abc,项目名称:doitphp,代码行数:27,代码来源:Cache_Redis.class.php


注:本文中的object::connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。