Code: Select all
private function deanonimize($sql){
$newsql = "";
$paramcount = 0;
for ($i=0; $i<strlen($sql); $i++){
$char = substr($sql, $i, 1);
if ($char == '?'){
$char = ":ph$paramcount";
$paramcount++;
}
$newsql = $newsql.$char;
}
return $newsql;
}
private function bindToStatement($statement, $binds){
$count = 0;
foreach($binds as $var){
$placeholder = ":ph$count";
if(!oci_bind_by_name($statement, $placeholder, $var)){
$this->setErrorMsg("- Error binding values in bindToStatement()");
$this->setOciErrorMsg(oci_error($statement));
$statement = false;
break;
}
$count++;
}
return $statement;
}
private function getResultSet($query, $bindsArray){
/*
* receives a query, parses and executes that query, puts the result
* set into an array and returns that array to the calling method
*/
$conn = $this->getConnection();
if($conn){
$query = $this->deanonimize($query);
$stmt = oci_parse($conn, $query);
if(!$this->bindToStatement(&$stmt, $bindsArray)){
$this->setErrorMsg("- Error binding values to prepared statement in getResultSet()");
return null;
}
}else{
$this->setErrorMsg("No connection to the database.");
return null;
}
if(oci_execute($stmt)){ // <-------------------- this is where I get the error
$rowCount = oci_fetch_all($stmt, $resultsArray, null, null,
OCI_FETCHSTATEMENT_BY_ROW+OCI_NUM);
}else{
$err = oci_error($stmt);
$this->setOciErrorMsg($err);
$resultsArray = array();
}
return $resultsArray;
}
At the indicated line, I get an ORA-01460 error. "ORA-01460: unimplemented or unreasonable conversion requested" and I have no idea what is causing this. My output from oci_error():
Code: Select all
oci_error[code]=1460
oci_error[message]=ORA-01460: unimplemented or unreasonable conversion requested
oci_error[offset]=18
oci_error[sqltext]=select privs from dbusers where username = :ph0 and pword = :ph1
Anybody? Help?
No idea EXACTLY what I did, but I transferred all of my code from classes to the calling page and got it working. One thing I know I did was ensure that I was using my database connection instead of an instance of my DBConnection class when calling oci_parse(). There were a handful of other changes made in the process, but that was the biggie that I documented. I then slowly put it back into the original functions, reintroduced the function calls and it worked.