Re: scope of classes in PHP
| From: | Jochem Maas | Date: | Mon, 13 Feb 2006 11:46:08 +0000 |
| Subject: | Re: scope of classes in PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-230305@lists.php.net to get a copy of this message | ||
Stuart Bailey wrote:
Hi I'm developing an app to administer LDAP (phpLdapAdmin is too complex for the customer). I have created an LDAP class, in a file class_ldap.php. It include methods for connecting to the server, binding a DN (effectively login), and adding posix groups. I have an index.php with include_once 'class_ldap.php', which allows me to login using the HTTP authentication mechanism. The connect method stores the resulting connection resource in a global variable (included in a config.php file). When I then go to add the posix group (from add_group.php, that also includes class_ldap.php), I find that the global connection variable is not valid. My question is, do I need to connect and authenticate with the LDAP server every time I want to perform an action, or is there a way to establish ayou need to establish a connection at the start of every request php handles, typically you perform one [major] 'action' per request so the short answer is: 'yes'. the connection to the LDAP server is a 'resource' type variable - php 'resources' are only valid for the duration of the script.
connection for the user's session, that is cleared when the user logs out. Many thanks, Stuart.