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 return @pg_connect("host=$server port=$config[sql_port]
14 dbname=$config[sql_database] user=$SQL_user
15 password=$SQL_passwd");
18 function da_sql_connect($config)
20 if ($config[sql_use_http_credentials] == 'yes'){
21 global $HTTP_SERVER_VARS;
22 $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
23 $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
26 $SQL_user = $config[sql_username];
27 $SQL_passwd = $config[sql_password];
29 return @pg_connect("host=$config[sql_server] port=$config[sql_port]
30 dbname=$config[sql_database] user=$SQL_user
31 password=$SQL_passwd");
34 function da_sql_pconnect($config)
36 if ($config[sql_use_http_credentials] == 'yes'){
37 global $HTTP_SERVER_VARS;
38 $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
39 $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
42 $SQL_user = $config[sql_username];
43 $SQL_passwd = $config[sql_password];
45 return @pg_pconnect("host=$config[sql_server] port=$config[sql_port]
46 dbname=$config[sql_database] user=$SQL_user
47 password=$SQL_passwd");
50 function da_sql_close($link,$config)
55 function da_sql_escape_string($string)
57 return addslashes($string);
60 function da_sql_query($link,$config,$query)
62 if ($config[sql_debug] == 'true')
63 print "<b>DEBUG(SQL,PG DRIVER): Query: <i>$query</i></b><br>\n";
64 return @pg_exec($link,$query);
67 function da_sql_num_rows($result,$config)
69 if ($config[sql_debug] == 'true')
70 print "<b>DEBUG(SQL,PG DRIVER): Query Result: Num rows:: " . @pg_numrows($result) . "</b><br>\n";
71 return @pg_numrows($result);
74 function da_sql_fetch_array($result,$config)
76 $row = @pg_fetch_array($result,$config[tmp_pg_array_num][$result]++,PGSQL_ASSOC);
77 if ($row && $config[sql_debug] == 'true'){
78 print "<b>DEBUG(SQL,PG DRIVER): Query Result: <pre>";
83 $config[tmp_pg_array_num][$result] = 0;
87 function da_sql_affected_rows($link,$result,$config)
89 if ($config[sql_debug] == 'true')
90 print "<b>DEBUG(SQL,PG DRIVER): Query Result: Affected rows:: " . @pg_cmdtuples($result) . "</b><br>\n";
91 return @pg_cmdtuples($result);
94 function da_sql_list_fields($table,$link,$config)
96 $res = @pg_exec($link,
97 "select count(*) from pg_attribute where attnum > '0' and
98 attrelid = (select oid from pg_class where relname='$table');");
100 $row = @pg_fetch_row($res,0);
104 $fields[num] = $row[0];
107 $res = @pg_exec($link,
108 "select attname from pg_attribute where attnum > '0' and
109 attrelid = (select oid from pg_class where relname='$table');");
118 function da_sql_num_fields($fields,$config)
124 function da_sql_field_name($fields,$num,$config)
127 $row = @pg_fetch_row($fields[res],$num);
133 function da_sql_error($link,$config)
135 return pg_errormessage($link);