/** * @param PersistConfig $config * @return SoapClient * @throws PersistException * */ protected function _connect(PersistConfig $config) { try { $paramArray = array('local_cert' => $config->get('certificate'), 'proxy_host' => $config->get('proxyhost'), 'proxy_port' => $config->get('proxyport'), 'proxy_login' => $config->get('username'), 'proxy_password' => $config->get('password'), 'trace' => 1); # Retornar em XML $resource = new \SoapClient($config->getDSN(), $paramArray); $this->_config = $config; return $resource; } catch (\Exception $ldape) { # @todo da mesma forma do PDO guardar log para o LDAP throw new PersistException($ldape->getMessage(), $ldape->getCode()); } }
/** * {@inheritdoc} * */ protected function _connect(PersistConfig $config) { try { $resource = new \PDO($config->getDSN(), $config->get('username'), $config->get('password')); # throws exception if anything goes wrong # only works with MySQL 4.x $resource->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); # get values as objects $resource->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_OBJ); # column names aways lowercase $resource->setAttribute(\PDO::ATTR_CASE, \PDO::CASE_LOWER); return $resource; } catch (\PDOException $pdoe) { # @todo um log com o error do PDO devera ser guardo throw new PersistException($pdoe->getMessage(), $pdoe->getCode()); } }
/** * Método que efetua a conexão com o serivdor Ldap. * * @param persistConfig $config * @throws PersistException * @see Parent::_connect() * */ protected function _connect(PersistConfig $config) { try { $resource = ldap_connect($config->getDSN()); $this->_config = $config; # Seto parametros de acordo com a versão do LDAP ldap_set_option($resource, LDAP_OPT_PROTOCOL_VERSION, $config->get('version')); # Seta se as referências segue a biblioteca LDAP e retornadas por servidores LDAP. ldap_set_option($resource, LDAP_OPT_REFERRALS, 0); return $resource; } catch (\Exception $exc) { throw new PersistException($exc->getMessage(), $exc->getCode()); } }