Line 45 | Line 45 |
---|
if ($new_link) {
|
if ($new_link) {
|
if (!function_exists('ocinlogon'))
| if (!function_exists('oci_new_connect'))
|
{
|
{
|
$this->connect_error = 'ocinlogon function does not exist, is oci extension installed?';
| $this->connect_error = 'oci_new_connect function does not exist, is oci extension installed?';
|
return $this->sql_error(''); }
|
return $this->sql_error(''); }
|
$this->db_connect_id = @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8');
| $this->db_connect_id = @oci_new_connect($this->user, $sqlpassword, $connect, 'UTF8');
|
} else if ($this->persistency) {
|
} else if ($this->persistency) {
|
if (!function_exists('ociplogon'))
| if (!function_exists('oci_pconnect'))
|
{
|
{
|
$this->connect_error = 'ociplogon function does not exist, is oci extension installed?';
| $this->connect_error = 'oci_pconnect function does not exist, is oci extension installed?';
|
return $this->sql_error(''); }
|
return $this->sql_error(''); }
|
$this->db_connect_id = @ociplogon($this->user, $sqlpassword, $connect, 'UTF8');
| $this->db_connect_id = @oci_pconnect($this->user, $sqlpassword, $connect, 'UTF8');
|
} else {
|
} else {
|
if (!function_exists('ocilogon'))
| if (!function_exists('oci_connect'))
|
{
|
{
|
$this->connect_error = 'ocilogon function does not exist, is oci extension installed?';
| $this->connect_error = 'oci_connect function does not exist, is oci extension installed?';
|
return $this->sql_error(''); }
|
return $this->sql_error(''); }
|
$this->db_connect_id = @ocilogon($this->user, $sqlpassword, $connect, 'UTF8');
| $this->db_connect_id = @oci_connect($this->user, $sqlpassword, $connect, 'UTF8');
|
}
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
| }
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
|
Line 101 | Line 101 |
---|
$cache->put('oracle_version', $this->sql_server_version); } */
|
$cache->put('oracle_version', $this->sql_server_version); } */
|
$this->sql_server_version = @ociserverversion($this->db_connect_id);
| $this->sql_server_version = @oci_server_version($this->db_connect_id);
|
return $this->sql_server_version; }
| return $this->sql_server_version; }
|
Line 119 | Line 119 |
---|
break;
case 'commit':
|
break;
case 'commit':
|
return @ocicommit($this->db_connect_id);
| return @oci_commit($this->db_connect_id);
|
break;
case 'rollback':
|
break;
case 'rollback':
|
return @ocirollback($this->db_connect_id);
| return @oci_rollback($this->db_connect_id);
|
break; }
| break; }
|
Line 405 | Line 405 |
---|
break; }
|
break; }
|
$this->query_result = @ociparse($this->db_connect_id, $query);
| $this->query_result = @oci_parse($this->db_connect_id, $query);
|
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
@ocibindbyname($this->query_result, $key, $array[$key], -1);
| @oci_bind_by_name($this->query_result, $key, $array[$key], -1);
|
}
|
}
|
$success = @ociexecute($this->query_result, OCI_DEFAULT);
| $success = @oci_execute($this->query_result, OCI_DEFAULT);
|
if (!$success) {
| if (!$success) {
|
Line 440 | Line 440 |
---|
{ return false; }
|
{ return false; }
|
| $safe_query_id = $this->clean_query_id($this->query_result);
|
if ($cache && $cache_ttl) {
|
if ($cache && $cache_ttl) {
|
$this->open_queries[(int) $this->query_result] = $this->query_result;
| $this->open_queries[$safe_query_id] = $this->query_result;
|
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0) {
|
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0) {
|
$this->open_queries[(int) $this->query_result] = $this->query_result;
| $this->open_queries[$safe_query_id] = $this->query_result;
|
} } else if ($this->debug_sql_explain)
| } } else if ($this->debug_sql_explain)
|
Line 481 | Line 483 |
---|
*/ function sql_affectedrows() {
|
*/ function sql_affectedrows() {
|
return ($this->query_result) ? @ocirowcount($this->query_result) : false;
| return ($this->query_result) ? @oci_num_rows($this->query_result) : false;
|
}
/**
| }
/**
|
Line 496 | Line 498 |
---|
$query_id = $this->query_result; }
|
$query_id = $this->query_result; }
|
if ($cache && $cache->sql_exists($query_id))
| $safe_query_id = $this->clean_query_id($query_id); if ($cache && $cache->sql_exists($safe_query_id))
|
{
|
{
|
return $cache->sql_fetchrow($query_id);
| return $cache->sql_fetchrow($safe_query_id);
|
}
if ($query_id) {
|
}
if ($query_id) {
|
$row = array(); $result = ocifetchinto($query_id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
if (!$result || !$row)
| if (!$row = oci_fetch_array($query_id, OCI_ASSOC + OCI_RETURN_NULLS))
|
{ return false; }
| { return false; }
|
Line 547 | Line 547 |
---|
$query_id = $this->query_result; }
|
$query_id = $this->query_result; }
|
if ($cache && $cache->sql_exists($query_id))
| $safe_query_id = $this->clean_query_id($query_id); if ($cache && $cache->sql_exists($safe_query_id))
|
{
|
{
|
return $cache->sql_rowseek($rownum, $query_id);
| return $cache->sql_rowseek($rownum, $safe_query_id);
|
}
if (!$query_id)
| }
if (!$query_id)
|
Line 558 | Line 559 |
---|
}
// Reset internal pointer
|
}
// Reset internal pointer
|
@ociexecute($query_id, OCI_DEFAULT);
| @oci_execute($query_id, OCI_DEFAULT);
|
// We do not fetch the row for rownum == 0 because then the next resultset would be the second row for ($i = 0; $i < $rownum; $i++)
| // We do not fetch the row for rownum == 0 because then the next resultset would be the second row for ($i = 0; $i < $rownum; $i++)
|
Line 573 | Line 574 |
---|
}
/**
|
}
/**
|
* {@inheritDoc}
| * {@inheritdoc}
|
*/
|
*/
|
function sql_nextid()
| public function sql_last_inserted_id()
|
{ $query_id = $this->query_result;
| { $query_id = $this->query_result;
|
Line 584 | Line 585 |
---|
if (preg_match('#^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)#is', $this->last_query_text, $tablename)) { $query = 'SELECT ' . $tablename[1] . '_seq.currval FROM DUAL';
|
if (preg_match('#^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)#is', $this->last_query_text, $tablename)) { $query = 'SELECT ' . $tablename[1] . '_seq.currval FROM DUAL';
|
$stmt = @ociparse($this->db_connect_id, $query);
| $stmt = @oci_parse($this->db_connect_id, $query);
|
if ($stmt) {
|
if ($stmt) {
|
$success = @ociexecute($stmt, OCI_DEFAULT);
| $success = @oci_execute($stmt, OCI_DEFAULT);
|
if ($success) {
|
if ($success) {
|
$temp_result = ocifetchinto($stmt, $temp_array, OCI_ASSOC + OCI_RETURN_NULLS); ocifreestatement($stmt);
| $temp_array = oci_fetch_array($stmt, OCI_ASSOC + OCI_RETURN_NULLS); oci_free_statement($stmt);
|
|
|
if ($temp_result)
| if (!empty($temp_array))
|
{ return $temp_array['CURRVAL']; }
| { return $temp_array['CURRVAL']; }
|
Line 622 | Line 623 |
---|
$query_id = $this->query_result; }
|
$query_id = $this->query_result; }
|
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
| $safe_query_id = $this->clean_query_id($query_id); if ($cache && $cache->sql_exists($safe_query_id))
|
{
|
{
|
return $cache->sql_freeresult($query_id);
| return $cache->sql_freeresult($safe_query_id);
|
}
|
}
|
if (isset($this->open_queries[(int) $query_id]))
| if (isset($this->open_queries[$safe_query_id]))
|
{
|
{
|
unset($this->open_queries[(int) $query_id]); return ocifreestatement($query_id);
| unset($this->open_queries[$safe_query_id]); return oci_free_statement($query_id);
|
}
return false;
| }
return false;
|
Line 683 | Line 685 |
---|
*/ function _sql_error() {
|
*/ function _sql_error() {
|
if (function_exists('ocierror'))
| if (function_exists('oci_error'))
|
{
|
{
|
$error = @ocierror(); $error = (!$error) ? @ocierror($this->query_result) : $error; $error = (!$error) ? @ocierror($this->db_connect_id) : $error;
| $error = @oci_error(); $error = (!$error) ? @oci_error($this->query_result) : $error; $error = (!$error) ? @oci_error($this->db_connect_id) : $error;
|
if ($error) {
| if ($error) {
|
Line 715 | Line 717 |
---|
*/ function _sql_close() {
|
*/ function _sql_close() {
|
return @ocilogoff($this->db_connect_id);
| return @oci_close($this->db_connect_id);
|
}
/**
| }
/**
|
Line 734 | Line 736 |
---|
$sql = "SELECT table_name FROM USER_TABLES WHERE table_name LIKE '%PLAN_TABLE%'";
|
$sql = "SELECT table_name FROM USER_TABLES WHERE table_name LIKE '%PLAN_TABLE%'";
|
$stmt = ociparse($this->db_connect_id, $sql); ociexecute($stmt); $result = array();
| $stmt = oci_parse($this->db_connect_id, $sql); oci_execute($stmt);
|
|
|
if (ocifetchinto($stmt, $result, OCI_ASSOC + OCI_RETURN_NULLS))
| if ($result = oci_fetch_array($stmt, OCI_ASSOC + OCI_RETURN_NULLS))
|
{ $table = $result['TABLE_NAME'];
| { $table = $result['TABLE_NAME'];
|
Line 746 | Line 747 |
---|
$statement_id = substr(md5($query), 0, 30);
// Remove any stale plans
|
$statement_id = substr(md5($query), 0, 30);
// Remove any stale plans
|
$stmt2 = ociparse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'"); ociexecute($stmt2); ocifreestatement($stmt2);
| $stmt2 = oci_parse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'"); oci_execute($stmt2); oci_free_statement($stmt2);
|
// Explain the plan $sql = "EXPLAIN PLAN SET STATEMENT_ID = '$statement_id' FOR $query";
|
// Explain the plan $sql = "EXPLAIN PLAN SET STATEMENT_ID = '$statement_id' FOR $query";
|
$stmt2 = ociparse($this->db_connect_id, $sql); ociexecute($stmt2); ocifreestatement($stmt2);
| $stmt2 = oci_parse($this->db_connect_id, $sql); oci_execute($stmt2); oci_free_statement($stmt2);
|
// Get the data from the plan $sql = "SELECT operation, options, object_name, object_type, cardinality, cost
| // Get the data from the plan $sql = "SELECT operation, options, object_name, object_type, cardinality, cost
|
Line 764 | Line 765 |
---|
START WITH id = 0 AND statement_id = '$statement_id' CONNECT BY PRIOR id = parent_id AND statement_id = '$statement_id'";
|
START WITH id = 0 AND statement_id = '$statement_id' CONNECT BY PRIOR id = parent_id AND statement_id = '$statement_id'";
|
$stmt2 = ociparse($this->db_connect_id, $sql); ociexecute($stmt2);
| $stmt2 = oci_parse($this->db_connect_id, $sql); oci_execute($stmt2);
|
|
|
$row = array(); while (ocifetchinto($stmt2, $row, OCI_ASSOC + OCI_RETURN_NULLS))
| while ($row = oci_fetch_array($stmt2, OCI_ASSOC + OCI_RETURN_NULLS))
|
{ $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); }
|
{ $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); }
|
ocifreestatement($stmt2);
| oci_free_statement($stmt2);
|
// Remove the plan we just made, we delete them on request anyway
|
// Remove the plan we just made, we delete them on request anyway
|
$stmt2 = ociparse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'"); ociexecute($stmt2); ocifreestatement($stmt2);
| $stmt2 = oci_parse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'"); oci_execute($stmt2); oci_free_statement($stmt2);
|
}
|
}
|
ocifreestatement($stmt);
| oci_free_statement($stmt);
|
if ($html_table) {
| if ($html_table) {
|
Line 794 | Line 794 |
---|
$endtime = explode(' ', microtime()); $endtime = $endtime[0] + $endtime[1];
|
$endtime = explode(' ', microtime()); $endtime = $endtime[0] + $endtime[1];
|
$result = @ociparse($this->db_connect_id, $query);
| $result = @oci_parse($this->db_connect_id, $query);
|
if ($result) {
|
if ($result) {
|
$success = @ociexecute($result, OCI_DEFAULT);
| $success = @oci_execute($result, OCI_DEFAULT);
|
if ($success) {
|
if ($success) {
|
$row = array();
| array();
|
|
|
while (ocifetchinto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS))
| while ($row = oci_fetch_array($result, OCI_ASSOC + OCI_RETURN_NULLS))
|
{ // Take the time spent on parsing rows into account }
|
{ // Take the time spent on parsing rows into account }
|
@ocifreestatement($result);
| @oci_free_statement($result);
|
} }
| } }
|
Line 817 | Line 817 |
---|
break; }
|
break; }
|
| }
/** * {@inheritDoc} */ function sql_quote($msg) { return '"' . $msg . '"';
|
} }
| } }
|