Home arrow PHP arrow Page 6 - Abstracting Oracle Connectivity with PHP/OCI8

Abstracting Oracle Connectivity with PHP/OCI8

In this article Lorenzo explains a neat utility to simplify connecting to an Oracle database using PHP/OCI8. This is sure to make DB operations between PHP and Oracle much easier and faster.

Author Info:
By: Dante Lorenso
Rating: 4 stars4 stars4 stars4 stars4 stars / 19
January 08, 2003
  1. · Abstracting Oracle Connectivity with PHP/OCI8
  2. · Oracle How-To The Hard Way
  3. · Wrapping it up into a PHP Class
  4. · How Do I Use This?
  5. · Those Pretty OCIBindByName Arguments
  6. · Switching Between Development, QA and Production Environments
  7. · Conclusion

print this article

Abstracting Oracle Connectivity with PHP/OCI8 - Switching Between Development, QA and Production Environments
(Page 6 of 7 )

We created that OCI8Hook class with database login and password abstraction for a reason.

In many corporations, you'll have multiple environments. You'll want to build your code against the development environment, test it on a QA environment and finally if all goes well, send it out to a production environment. Well, that's one more advantage to having your connection strings abstracted into the function getDBAuth($sid) { ... } function.

To toggle between environments, simple change the connect string for your DBNAME. Say I'm running all my queries against 'DBXYZ' with the following $stmt = $this->query("DBXYZ", $sql, $bargs);. Well, by simply changing the connect string from this:

case "DBXYZ": return (array("usernam1", "secret1", "DBXYZ"));
To something like this:

case "DBXYZ": return (array("usernam1", "secret1", "TESTDB"));

Or if you wanted to be really fancy, you might consider sticking an IF statement in there like this:

case "DBXYZ":
if (--I'm on the DEV environment--)
return (array("usernam1", "secret1", "DEVDB"));
else if (--I'm on the QA environment--)
return (array("usernam1", "secret1", "TESTDB"));
return (array("usernam1", "secret1", "PRODDB"));

blog comments powered by Disqus

- Removing Singletons in PHP
- Singletons in PHP
- Implement Facebook Javascript SDK with PHP
- Making Usage Statistics in PHP
- Installing PHP under Windows: Further Config...
- File Version Management in PHP
- Statistical View of Data in a Clustered Bar ...
- Creating a Multi-File Upload Script in PHP
- Executing Microsoft SQL Server Stored Proced...
- Code 10x More Efficiently Using Data Access ...
- A Few Tips for Speeding Up PHP Code
- The Modular Web Page
- Quick E-Commerce with PHP and PayPal
- Regression Testing With JMeter
- Building an Iterator with PHP

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials