OCI 8 oracle connection

Talk about installation process and problems

Moderator: alexandrleonenko

sexyTrojan
Newbie
Newbie
Posts: 1
Joined: Jun 4th, '10, 02:53

OCI 8 oracle connection

Postby sexyTrojan » Jun 4th, '10, 03:22

Hey,

I'm having a problem connecting to the database using the datagrid.class.php. I'm trying out verison 4.2.8 before purchasing. Here is the code
FYI: the db is on a vm so it's not a localhost

i'm getting this error:

[nativecode=ORA-12154: TNS:could not resolve the connect identifier specified]


Code: Select all



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>PHP DG</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta name="keywords" content="php, datagrid" />
    <meta name="description" content="php datagrid." />
  </head>

<body>


<?php

define ("DATAGRID_DIR", "datagrid_4_2_8/");                   
define ("PEAR_DIR", "datagrid_4_2_8/pear/");                   

$DB_USER='scott';           
$DB_PASS='tiger';               
$DB_HOST='myhost';       
$DB_NAME='myDB;         


require_once(DATAGRID_DIR.'datagrid.class.php');
require_once(PEAR_DIR.'PEAR.php');
require_once(PEAR_DIR.'DB.php');

ob_start();
$db_conn = DB::factory('oci8'); 
$result_conn = $db_conn->connect(DB::parseDSN('oci8://'.$DB_USER.':'.$DB_PASS.'@'.$DB_HOST.'/'.$DB_NAME));
if(DB::isError($result_conn)){ die($result_conn->getDebugInfo()); }


$sql = "SELECT customer_id, emp_id  FROM customers";
##  *** set encoding and collation (default: utf8/utf8_unicode_ci)
$dg_encoding = "utf8";
$dg_collation = "utf8_unicode_ci";
$dgrid->SetEncoding($dg_encoding, $dg_collation);
##  *** set needed options and create a new class instance
$debug_mode = true;        /* display SQL statements while processing */   
$messaging = true;          /* display system messages on a screen */
$unique_prefix = "a_";    /* prevent overlays - must be started with a letter */
$dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR);
##  *** set data source with needed options
$default_order_field = "emp_id";
$default_order_type = "ASC";
$dgrid->DataSource($db_conn, $sql, $default_order_field, $default_order_type);      

$dgrid->WriteCssClass();
$dgrid->Bind();
ob_end_flush();



Thanks

administrator
Site Admin
Site Admin
Posts: 6105
Joined: Jan 7th, '09, 23:18
Contact:

Re: OCI 8 oracle connection

Postby administrator » Jun 7th, '10, 18:59

Version 4.2.8 doesn't work properly with oracle, but for testing you may use:

## *** (example of Oracle connection string) - oci8
## *** 1. $DB_NAME = "localhost:1521/mydatabase";
## *** $result_conn = $db_conn->connect(DB::parseDSN('oci8://root:12345@localhost/'.$DB_NAME));
## *** 2. $DB_DESCR = "(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = xx.xx.xx.xx)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = dev.domain.com)))";
## *** $result_conn = $db_conn->connect(DB::parseDSN('oci8://root:12345@'.$DB_DESCR));


Return to “Installation”