From 05d8d22d31ccf4bc747ad3fb9801ff7c5d2ff8ea Mon Sep 17 00:00:00 2001 From: pnixon Date: Sun, 20 Mar 2005 17:07:25 +0000 Subject: [PATCH] Add native oracle support (Using the PHP OCI8 driver) to dialupadmin --- dialup_admin/lib/sql/drivers/oracle/functions.php3 | 129 +++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 dialup_admin/lib/sql/drivers/oracle/functions.php3 diff --git a/dialup_admin/lib/sql/drivers/oracle/functions.php3 b/dialup_admin/lib/sql/drivers/oracle/functions.php3 new file mode 100644 index 0000000..9e5b766 --- /dev/null +++ b/dialup_admin/lib/sql/drivers/oracle/functions.php3 @@ -0,0 +1,129 @@ +DEBUG(SQL,OCI DRIVER): Query: $query
\n"; + } + $statement = OCIParse($link,$query); + OCIExecute($statement); + return $statement; +} + +function da_sql_num_rows($statement,$config) +{ + // Unfortunately we need to fetch the statement as ocirowcount doesn't work on SELECTs + $rows = OCIFetchStatement($statement,$res); + + if ($config[sql_debug] == 'true'){ + // print "DEBUG(SQL,OCI DRIVER): Query Result: Num rows:: " . @ocirowcount($statement) . "
\n"; + print "DEBUG(SQL,OCI DRIVER): Query Result: Num rows:: " . $rows . "
\n"; + } + // Unfortunately we need to re-execute because the statement cursor is reset after OCIFetchStatement :-( + OCIExecute($statement); + return $rows; +} + + +function da_sql_fetch_array($statement,$config) +{ + OCIFetchInto($statement, $temprow, OCI_ASSOC); + $row = array_change_key_case($temprow, CASE_LOWER); + if ($config[sql_debug] == 'true') { + print "DEBUG(SQL,OCI DRIVER): Query Result:
";
+                print_r($row);
+                print "
\n"; + } + return $row; +} + + +function da_sql_affected_rows($link,$statement,$config) +{ + if ($config[sql_debug] == 'true') + print "DEBUG(SQL,OCI DRIVER): Query Result: Affected rows:: " . @ocirowcount($statement) . "
\n"; + return @ocirowcount($statement); +} + +function da_sql_list_fields($table,$link,$config) +{ + $res = @da_sql_query($link,$config,"SELECT * from $table WHERE ROWNUM <=1"); + if ($res){ + $fields[res]=Array(); + for ($i = 1;$i<=ocinumcols($res);$i++) { + array_push($fields[res],strtolower(OCIColumnName($res,$i))); + } + $fields[num]=@ocinumcols($res); + }else{ + return NULL; + } + return $fields; +} + +function da_sql_num_fields($fields,$config) +{ + return $fields[num]; +} + +function da_sql_field_name($fields,$num,$config) +{ + return $fields[res][$num]; +} + +function da_sql_error($link,$config) +{ + return ocierror($link); +} +?> -- 2.1.4