note 107465 added to oci8.requirements

From: Date: Fri, 10 Feb 2012 18:33:44 +0000
Subject: note 107465 added to oci8.requirements
Groups: php.notes 
Request: Send a blank email to php-notes+get-186059@lists.php.net to get a copy of this message
How to connect from PHP to an Oracle database using OID (Oracle Internet Directory): OID is like a lookup index that contains connection strings for connecting to various databases. Without OID, a database connection string would be stored directly in the code settings and used by the PHP code to connect to a database. With OID, a lookup can be made to the OID LDAP to acquire the database connection string. Then the PHP code will use the acquired database connection string to connect to the database as before. OID allows a DBA to manage/change which database server that an application uses without having to change any database settings in the PHP application itself or on the application server. Here are the basic steps for PHP to connect to a database via OID: - The DBA should provide you the connection information for the OID LDAP as well as the username/password for the database connection. - Connect to the OID LDAP using the provided information - Search for the appropriate LDAP record - Get the connection string data from the record attribute, "orclnetdescstring" - Close the LDAP connection - Use the acquired connection string data to connect to the database as usual using the provided database username/password. Here is basic sample code to do this: // Get connection string from OID LDAP $ds=ldap_connect($servername,$serverport); // Connect to ldap $r=ldap_bind($ds); // Bind to ldap $sr = ldap_search($ds, "cn=OracleContext,dc=___,dc=___,dc=___", "cn=$sid"); // Run query $info = ldap_get_entries($ds, $sr); // Get entries ldap_close($ds); // Close connection $dbconnectstring = $info[0]["orclnetdescstring"][0]; // Extract db connect string from ldap search result array // Connect to database using acquired connection string from OID $dbconnection = oci_connect ($username,$password,$dbconnectstring); ---- Server IP: 69.147.83.197 Probable Submitter: 146.18.173.106 (proxied: 199.81.66.130) ---- Manual Page -- http://www.php.net/manual/en/oci8.requirements.php Edit -- https://master.php.net/note/edit/107465 Del: integrated -- https://master.php.net/note/delete/107465/integrated Del: useless -- https://master.php.net/note/delete/107465/useless Del: bad code -- https://master.php.net/note/delete/107465/bad+code Del: spam -- https://master.php.net/note/delete/107465/spam Del: non-english -- https://master.php.net/note/delete/107465/non-english Del: in docs -- https://master.php.net/note/delete/107465/in+docs Del: other reasons-- https://master.php.net/note/delete/107465 Reject -- https://master.php.net/note/reject/107465 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#186059) next »