• home
  • forum
  • my
  • kt
  • download
  • Zend php connect to oracle using tnsnames

    Author: 2009-03-08 11:33:18 From:

    This few days I am trying to configure my Linux server Zend PHP to connect oracle by using the tnsnames.ora profile.

    For my finding, there are several ways to do so.

    1. Install the oracle clients into the Linux server & it will set the environment variable TNS_ADMIN to the correct path for the tnsnames.ora. But I not taking this approach due to the Linux server is not under our control.

    2. Create a shell script & enable the shell script to execute once the server starting & export the TNS_ADMIN variable to path “/usr/local/Zend/Core/network/admin/” directory (the path is where the tnsnames.ora located, you may also change the path to any directory where your tnsnames.ora located)

    3. In your php script, add in a command to set the environment varialbe TNS_ADMIN to “/usr/local/Zend/Core/network/admin/” by using php command. 
    putenv(”TNS_ADMIN=/usr/local/Zend/Core/network/admin”); 
    Add in this command before establish connection to oracle. 

    I am using third solution due to I got not control on the Linux server, I only able to access on the application layer.  Below is some coding example.

    //Previous connection method
    function connect(){
         $database = ociplogon(”username”, “password”,”//192.168.0.50/ora_instance_name”);
         return $datbases;
    }

    //Enhanced method using tnsnames profile
    function connect(){
         putenv(”TNS_ADMIN=/usr/local/Zend/Core/network/admin/”);
         $database = ociplogon(”username”, “password”,”ora_profile_name_in_tnsnames”);
         return $datbases;
    }

    discuss this topic to forum

    relation tutorial

    No information

    Category

      Ad Management (6)
      Calendars (3)
      Chat Systems (8)
      Content Management (41)
      Cookies and Sessions (12)
      Counters (15)
      Database Related (33)
      Date and Time (13)
      Development (19)
      Discussion Boards (8)
      E Commerce (8)
      Email Systems (13)
      Error Handling (7)
      File Manipulation (24)
      Flash and PHP (6)
      Form Processing (19)
      Guestbooks (12)
      Image Manipulation (21)
      Installing PHP (7)
      Introduction to PHP (23)
      Link Indexing (8)
      Mailing List Management (9)
      Miscellaneous (53)
      Networking (8)
      News Publishing (9)
      OOP (24)
      PEAR (6)
      PHP vs Other Languages (2)
      Polls and Voting (6)
      Postcards (1)
      Randomizing (14)
      Redirection (11)
      Searching (9)
      Security (29)
      Site Navigation (16)
      User Authentication (14)
      WAP and WML (7)
      Web Fetching (8)
      Web Traffic Analysis (15)
      XML and PHP (16)

    New

    Hot