[eluser]Unknown[/eluser]
Hello. I'm trying to use oci8 driver for calling stored procedure, but getting database error message without number or description, just with SQL code.
I have changed code in oci8_driver.php twice:
1)changed:
Code:
function db_connect()
{
return @ocilogon($this->username, $this->password, $this->hostname);
}
to:
Code:
function db_connect()
{
return @ocilogon($this->username, $this->password, $this->hostname, $this->char_set);
}
for proper display of cyrillic symbols,
2)changed
Code:
function _bind_params($params)
{
if ( ! is_array($params) OR ! is_resource($this->stmt_id))
{
return;
}
foreach ($params as $param)
{
foreach (array('name', 'value', 'type', 'length') as $val)
{
if ( ! isset($param[$val]))
{
$param[$val] = '';
}
}
ocibindbyname($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']);
}
}
to
Code:
function _bind_params($params)
{
if ( ! is_array($params) OR ! is_resource($this->stmt_id))
{
return;
}
foreach ($params as $param)
{
foreach (array('name', 'value', 'type', 'length') as $val)
{
if ( ! isset($param[$val]))
{
$param[$val] = FALSE;
}
}
ocibindbyname($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']);
}
}
Because of getting warnings about type mismatch.
controllers code:
Code:
<?php
class Test extends Controller{
function index(){
$user=array('login'=>'someuser',
'password'=>'somepass',
);
$transaction=array('result'=>'-1');
$params=array(
array('name'=>':p_login' , 'value'=>$user['login'] , 'length'=>'255'),
array('name'=>':p_passwd' , 'value'=>$user['password'] , 'length'=>'255'),
array('name'=>':p_result', 'value'=>$transaction['result'], 'length'=>'255')
);
$this->db->stored_procedure('test_package', 'test_procedure', $params);
echo $transaction['result'];
}
}
?>
Exactly same SQL code worked fine in clear PHP.
How to handle error?