Oracle
From RadPHP XE2 Documentation
Contents |
Initial Setup
To get PHP and Oracle working together, follow these steps:
- Get Instant Client from oracle.com/technetwork/database/features/instant-client/index-097480.html.
- Extract the archive somewhere.
- Get your system to recognize the .dll files in Instant Client folder. You can do it different ways:
- Copy all .dll files in Instant Client folder into your Windows\System32 directory.
- Point ORACLE_HOME to Instant Client folder. Check orafaq.com/wiki/ORACLE_HOME for more information.
- Uncomment (remove the ; at the beginning) the following line on RadPHP php.ini.template file:
- ;extension=php_oci8.dll
Usage
Data Explorer Setup
When you set up a connection to an Oracle database from the Data Explorer, you must fill Database Name property with the database server address and database name, separated by a slash (/). For example: 127.0.0.1/database.
Database Setup
To use a Database component with Oracle, set it up so it uses Oracle driver:
- DriverName: oracle.
Do not forget to fill also the rest of the basic information.
Work With PHP
// Set Connection Data $database = 'database'; // Server address and database name like this: //server/database. $user = 'user'; // Username to access the database. $password = 'password'; // Password for the user. // Establish Connection $connection = oci_connect($user, $password, $server); // Connection Test if (!$connection) echo 'Oracle Database could not be reached'; else echo 'Succesfully connected to Oracle Database'; // Perform a Query $sql = "SELECT * FROM table"; $statement = oci_parse ($connection, $sql); oci_execute ($statement); while ($row = oci_fetch_assoc($statement)) { print_r($row); } oci_free_statement($statement);
See Also
- php.net/oracle (Oracle OCI8 PHP Documentation)
- oracle.com/technetwork/topics/php (Oracle PHP Help)