Changing the question in the hope of success...
I have an oracleDB
class that begins...
class oracleDB {
private $connec, $affectedRows, $parseStatement;
public $err;
function __construct($user,$pwd,$db){
$this->connec = OCILogon($user, $pwd, $db);
if ( ! $this->connec ) {
return false;
}
}
function parse($sql){
$operation = strtolower(substr(ltrim($sql), 0, 6));
//update and delete must have where clause
if($operation == "update" || $operation == "delete"){
if(!stripos($sql, "where")){
$this->err = "Update or delete query with no where clause!";
return false;
}
}
$this->parseStatement = oci_parse($this->connec, $sql);
if ($this->parseStatement){
var_dump($this->parseStatement);
return true;
} else {
return false;
}
}//parse
}
I can connect to oracle and get data back using a simple connect string and select *
statement.
However when i pass the connection to a variable
$conn_test = new OracleDB($user,$pwd,$db);
and then use and include('somefile.php');
and another class
class SomeOtherClass{
function somemethod() {
global $conn_test;
$sql='select * from foobar';
$conn_test->parse($sql);
//...
}
}
I get a fatal error on parse (on a non object)
$conn_test
appears to lose it's value (is NULL) and i can't parse my query / return data
- I have tried passing the $conn_test into the method as a variable, but this doesn't seem to work either.
Why this error appears?