_config['caching']; } /** * Have we got a bound connection to the LDAP server * * @return boolean TRUE|FALSE */ public function connected() { return ($this->_connection AND $this->_connected); } /** * Return the connection resource * * @return resource LDAP Resource Identifier */ public function connection() { return $this->_connection; } /** * A wrapper for parent::instance(), so that we can create multiple connections * to the same LDAP server with different credentials/purposes. * * Get a singleton Database instance. If configuration is not specified, * it will be loaded from the database configuration file using the same * group as the name. * * // Load the default database * $db = LDAP::factory(); * * // Create a custom configured instance * $db = LDAP:factory('auth','custom', $config); * * @param string A free form usage name, for this connection * @param string A database configuration name, as per parent::instance() * @param array An alternative database configuration to use for $name. * @see Database::instance(); * @return LDAP::instance(); * * @note We cant call this instance() like our parent, because of the additional parameter * we need. */ public static function factory($usage=NULL,$name=NULL,array $config=NULL) { // Use the default instance name if ($usage === NULL) $usage = LDAP::$usage; if (! isset(Database::$instances[$usage])) { // Use the default instance name if ($name === NULL) $name = Database::$default; // Load the configuration for this database if ($config === NULL) $config = Kohana::$config->load('database')->$name; } return parent::instance($usage,$config); } /** * @defunct This static function is defunct, you need to use factory() instead. * @see LDAP::factory(); */ public static function instance($name=NULL,array $config=NULL) { throw Kohana_Exception('Sorry, you cant use instance(), you need to use factory()'); } public function setSchema(Model_LDAP_Schema $orm) { $this->_schema = $orm; } public function schema() { return $this->_schema; } } ?>