2 function da_sql_host_connect($server,$config)
4 if ($config[sql_use_http_credentials] == 'yes'){
5 global $HTTP_SERVER_VARS;
6 $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
7 $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
10 $SQL_user = $config[sql_username];
11 $SQL_passwd = $config[sql_password];
13 if ($config[sql_debug] == 'true')
14 print "<b>DEBUG(SQL,MYSQL DRIVER): Connect: User=$SQL_user,Password=$SQL_passwd </b><br>\n";
15 return @pg_connect("host=$server port=$config[sql_port]
16 dbname=$config[sql_database] user=$SQL_user
17 password=$SQL_passwd");
20 function da_sql_connect($config)
22 if ($config[sql_use_http_credentials] == 'yes'){
23 global $HTTP_SERVER_VARS;
24 $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
25 $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
28 $SQL_user = $config[sql_username];
29 $SQL_passwd = $config[sql_password];
31 if ($config[sql_debug] == 'true')
32 print "<b>DEBUG(SQL,MYSQL DRIVER): Connect: User=$SQL_user,Password=$SQL_passwd </b><br>\n";
33 return @pg_connect("host=$config[sql_server] port=$config[sql_port]
34 dbname=$config[sql_database] user=$SQL_user
35 password=$SQL_passwd");
38 function da_sql_pconnect($config)
40 if ($config[sql_use_http_credentials] == 'yes'){
41 global $HTTP_SERVER_VARS;
42 $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
43 $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
46 $SQL_user = $config[sql_username];
47 $SQL_passwd = $config[sql_password];
49 if ($config[sql_debug] == 'true')
50 print "<b>DEBUG(SQL,MYSQL DRIVER): Connect: User=$SQL_user,Password=$SQL_passwd </b><br>\n";
51 return @pg_pconnect("host=$config[sql_server] port=$config[sql_port]
52 dbname=$config[sql_database] user=$SQL_user
53 password=$SQL_passwd");
56 function da_sql_close($link,$config)
61 function da_sql_escape_string($string)
63 return addslashes($string);
66 function da_sql_query($link,$config,$query)
68 if ($config[sql_debug] == 'true')
69 print "<b>DEBUG(SQL,PG DRIVER): Query: <i>$query</i></b><br>\n";
70 return @pg_exec($link,$query);
73 function da_sql_num_rows($result,$config)
75 if ($config[sql_debug] == 'true')
76 print "<b>DEBUG(SQL,PG DRIVER): Query Result: Num rows:: " . @pg_numrows($result) . "</b><br>\n";
77 return @pg_numrows($result);
80 function da_sql_fetch_array($result,$config)
82 $row = @pg_fetch_array($result,$config[tmp_pg_array_num][$result]++,PGSQL_ASSOC);
83 if ($row && $config[sql_debug] == 'true'){
84 print "<b>DEBUG(SQL,PG DRIVER): Query Result: <pre>";
89 $config[tmp_pg_array_num][$result] = 0;
93 function da_sql_affected_rows($link,$result,$config)
95 if ($config[sql_debug] == 'true')
96 print "<b>DEBUG(SQL,PG DRIVER): Query Result: Affected rows:: " . @pg_cmdtuples($result) . "</b><br>\n";
97 return @pg_cmdtuples($result);
100 function da_sql_list_fields($table,$link,$config)
102 $res = @pg_exec($link,
103 "select count(*) from pg_attribute where attnum > '0' and
104 attrelid = (select oid from pg_class where relname='$table');");
106 $row = @pg_fetch_row($res,0);
110 $fields[num] = $row[0];
113 $res = @pg_exec($link,
114 "select attname from pg_attribute where attnum > '0' and
115 attrelid = (select oid from pg_class where relname='$table');");
124 function da_sql_num_fields($fields,$config)
130 function da_sql_field_name($fields,$num,$config)
133 $row = @pg_fetch_row($fields[res],$num);
139 function da_sql_error($link,$config)
141 return pg_errormessage($link);