2 function da_sql_connect($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=$config[sql_server] port=$config[sql_port]
14 dbname=$config[sql_database] user=$SQL_user
15 password=$SQL_passwd");
18 function da_sql_pconnect($config)
20 return @pg_pconnect("host=$config[sql_server] port=$config[sql_port]
21 dbname=$config[sql_database] user=$config[sql_username]
22 password=$config[sql_password]");
25 function da_sql_close($link,$config)
30 function da_sql_query($link,$config,$query)
32 if ($config[sql_debug] == 'true')
33 print "<b>DEBUG(SQL,PG DRIVER): Query: <i>$query</i></b><br>\n";
34 return @pg_exec($link,$query);
37 function da_sql_num_rows($result,$config)
39 if ($config[sql_debug] == 'true')
40 print "<b>DEBUG(SQL,PG DRIVER): Query Result: Num rows:: " . @pg_numrows($result) . "</b><br>\n";
41 return @pg_numrows($result);
44 function da_sql_fetch_array($result,$config)
46 if ($config[sql_debug] == 'true'){
47 print "<b>DEBUG(SQL,PG DRIVER): Query Result: ";
48 print_r(@pg_fetch_array($result,$config[tmp_pg_array_num][$result]++,PGSQL_ASSOC));
51 $row = @pg_fetch_array($result,$config[tmp_pg_array_num][$result]++,PGSQL_ASSOC);
53 $config[tmp_pg_array_num][$result] = 0;
57 function da_sql_affected_rows($link,$result,$config)
59 if ($config[sql_debug] == 'true')
60 print "<b>DEBUG(SQL,PG DRIVER): Query Result: Affected rows:: " . @pg_cmdtuples($result) . "</b><br>\n";
61 return @pg_cmdtuples($result);
64 function da_sql_list_fields($table,$link,$config)
66 $res = @pg_exec($link,
67 "select count(*) from pg_attribute where attnum > '0' and
68 attrelid = (select oid from pg_class where relname='$table');");
70 $row = @pg_fetch_row($res,0);
74 $fields[num] = $row[0];
77 $res = @pg_exec($link,
78 "select attname from pg_attribute where attnum > '0' and
79 attrelid = (select oid from pg_class where relname='$table');");
88 function da_sql_num_fields($fields,$config)
94 function da_sql_field_name($fields,$num,$config)
97 $row = @pg_fetch_row($fields[res],$num);
103 function da_sql_error($link,$config)
105 return pg_errormessage($link);