PHP to remote Oracle server connection on windows - Notes
PHP to remote Oracle server connection on windows
PHP to remote Oracle server connection on windows
Xampp 1.7.1
Apache 2.2.11
PHP 5.2.9-2
Oracle Instant client 10.2.0.2
1. Download the oracle server compatible oracle instant client fromhttp://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html
2. Unzip the folder and the copy the path.
3. Create system environment variable ORACLE_HOME = above path
4. Add %ORACLE_HOME% to “Path” system variable
5. Uncomment extension=php_oci8.dll for oci support and extension=php_pdo_oci.dll for PDO_OCI from php.ini
6. Remove oci.dll, ociw32.dll and orannzsbb10.dll from c:\xampp\php and c:\xampp\apache\bin folder if any.
Note: ensure that there are only single copies of these three dlls and they are under instantclient folder only.
7. Restart apache.
8. You are done
———————–PDO_OCI—————————————
Test program for PDO_OCI:
try {
$conn = new PDO(‘oci:dbname=//serverip:1521/SID;’, ‘username’, ‘password’);
foreach ($conn->query(‘SELECT * from tabs’) as $row) {
print_r($row);
}
}
catch (PDOException $e) {
echo “Failed to obtain database handle ” . $e->getMessage();
}
———————————oci————————————
$db =”(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = serverip)(PORT = 1512))
(CONNECT_DATA = (SID = sid)))”;
$conn = oci_connect(“user”, “pass”, $db);
$stmt = oci_parse($conn, “select * from tabs”);
oci_execute($stmt, OCI_DEFAULT);
while (oci_fetch($stmt)) {
echo $conn . ” [" . oci_result($stmt, "TABLE_NAME") . "]\n\n”;
}
———————————————————————
For Symfony
1. Create oracle folder under lib\vendor\symfony\lib\plugins\sfPropelPlugin\lib\vendor\propel-generator\classes\propel\engine\database\reverse\ and add OracleSchemaParser.php to it.
For Propel 1.3 you can download from here.
http://propel.phpdb.org/trac/attachment/ticket/644/OracleSchemaParser.php
2. Propel.ini
propel.database = oracle
propel.database.driver = oracle
propel.database.url = oci:dbname=//192.168.19.5:1521/glamorcl
propel.database.creole.url = ${propel.database.url}
propel.database.user = ade_data_dev
propel.database.password = ade_data_dev
3. databse.yml
all:
propel:
class: sfPropelDatabase
param:
classname: PropelPDO
phptype: oracle
dsn: oci:dbname=//192.168.19.5:1521/glamorcl
username: ade_data_dev
password: ade_data_dev
persistent: true
pooling: true
4. Comment $con->exec(“SET NAMES ‘” . $charset . “‘”); as in file DBAdaptor.php
//lib\vendor\symfony\lib\plugins\sfPropelPlugin\lib\vendor\propel\adaptor\DBAdaptor.php
public function setCharset(PDO $con, $charset)
{
//$con->exec(“SET NAMES ‘” . $charset . “‘”);
}
5. You are done.