3 function da_sql_limit($limit,$point,$config)
9 return "AND ROWNUM <= $limit";
15 function da_sql_host_connect($server,$config)
17 if ($config[sql_use_http_credentials] == 'yes'){
18 global $HTTP_SERVER_VARS;
19 $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
20 $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
23 $SQL_user = $config[sql_username];
24 $SQL_passwd = $config[sql_password];
26 $link = @ocilogon($SQL_user, $SQL_passwd, $config[sql_database]);
27 $res = @da_sql_query($link,$config,"ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT='YYYY-MM-DD HH24:MI:SS.FF TZH:TZM'");
31 function da_sql_connect($config)
33 if ($config[sql_use_http_credentials] == 'yes'){
34 global $HTTP_SERVER_VARS;
35 $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
36 $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
39 $SQL_user = $config[sql_username];
40 $SQL_passwd = $config[sql_password];
42 $link = @ocilogon($SQL_user, $SQL_passwd, $config[sql_database]);
43 $res = @da_sql_query($link,$config,"ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT='YYYY-MM-DD HH24:MI:SS.FF TZH:TZM'");
47 function da_sql_pconnect($config)
49 if ($config[sql_use_http_credentials] == 'yes'){
50 global $HTTP_SERVER_VARS;
51 $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
52 $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
55 $SQL_user = $config[sql_username];
56 $SQL_passwd = $config[sql_password];
58 $link = @ociplogon($SQL_user, $SQL_passwd, $config[sql_database]);
59 $res = @da_sql_query($link,$config,"ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT='YYYY-MM-DD HH24:MI:SS.FF TZH:TZM'");
63 function da_sql_close($link,$config)
68 function da_sql_escape_string($string)
70 return addslashes($string);
73 function da_sql_query($link,$config,$query)
75 $trimmed_query = rtrim($query, ";");
76 if ($config[sql_debug] == 'true') {
77 print "<b>DEBUG(SQL,OCI DRIVER): Query: <i>$trimmed_query</i></b><br>\n";
79 $statement = OCIParse($link,$trimmed_query);
80 OCIExecute($statement);
84 function da_sql_num_rows($statement,$config)
86 // Unfortunately we need to fetch the statement as ocirowcount doesn't work on SELECTs
87 $rows = OCIFetchStatement($statement,$res);
89 if ($config[sql_debug] == 'true'){
90 print "<b>DEBUG(SQL,OCI DRIVER): Query Result: Num rows:: " . $rows . "</b><br>\n";
92 // Unfortunately we need to re-execute because the statement cursor is reset after OCIFetchStatement :-(
93 OCIExecute($statement);
98 function da_sql_fetch_array($statement,$config)
100 OCIFetchInto($statement, $temprow, OCI_ASSOC);
101 $row = array_change_key_case($temprow, CASE_LOWER);
102 if ($config[sql_debug] == 'true') {
103 print "<b>DEBUG(SQL,OCI DRIVER): Query Result: <pre>";
105 print "</b></pre>\n";
111 function da_sql_affected_rows($link,$statement,$config)
113 if ($config[sql_debug] == 'true')
114 print "<b>DEBUG(SQL,OCI DRIVER): Query Result: Affected rows:: " . @ocirowcount($statement) . "</b><br>\n";
115 return @ocirowcount($statement);
118 function da_sql_list_fields($table,$link,$config)
120 $res = @da_sql_query($link,$config,"SELECT * from $table WHERE ROWNUM <=1");
122 $fields[res]=Array();
123 for ($i = 1;$i<=ocinumcols($res);$i++) {
124 array_push($fields[res],strtolower(OCIColumnName($res,$i)));
126 $fields[num]=@ocinumcols($res);
133 function da_sql_num_fields($fields,$config)
138 function da_sql_field_name($fields,$num,$config)
140 return $fields[res][$num];
143 function da_sql_error($link,$config)
145 return ocierror($link);