2 function da_sql_limit($limit,$point,$config)
10 return "LIMIT $limit";
13 function da_sql_host_connect($server,$config)
15 if ($config[sql_use_http_credentials] == 'yes'){
16 global $HTTP_SERVER_VARS;
17 $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
18 $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
21 $SQL_user = $config[sql_username];
22 $SQL_passwd = $config[sql_password];
24 if ($config[sql_debug] == 'true')
25 print "<b>DEBUG(SQL,PG DRIVER): Connect: User=$SQL_user,Password=$SQL_passwd </b><br>\n";
26 return @pg_connect("host=$server port=$config[sql_port]
27 dbname=$config[sql_database] user=$SQL_user
28 password=$SQL_passwd");
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 if ($config[sql_debug] == 'true')
43 print "<b>DEBUG(SQL,PG DRIVER): Connect: User=$SQL_user,Password=$SQL_passwd </b><br>\n";
44 return @pg_connect("host=$config[sql_server] port=$config[sql_port]
45 dbname=$config[sql_database] user=$SQL_user
46 password=$SQL_passwd");
49 function da_sql_pconnect($config)
51 if ($config[sql_use_http_credentials] == 'yes'){
52 global $HTTP_SERVER_VARS;
53 $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
54 $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
57 $SQL_user = $config[sql_username];
58 $SQL_passwd = $config[sql_password];
60 if ($config[sql_debug] == 'true')
61 print "<b>DEBUG(SQL,PG DRIVER): Connect: User=$SQL_user,Password=$SQL_passwd </b><br>\n";
62 return @pg_pconnect("host=$config[sql_server] port=$config[sql_port]
63 dbname=$config[sql_database] user=$SQL_user
64 password=$SQL_passwd");
67 function da_sql_close($link,$config)
72 function da_sql_escape_string($string)
74 return addslashes($string);
77 function da_sql_query($link,$config,$query)
79 if ($config[sql_debug] == 'true')
80 print "<b>DEBUG(SQL,PG DRIVER): Query: <i>$query</i></b><br>\n";
81 return @pg_query($link,$query);
84 function da_sql_num_rows($result,$config)
86 if ($config[sql_debug] == 'true')
87 print "<b>DEBUG(SQL,PG DRIVER): Query Result: Num rows:: " . @pg_numrows($result) . "</b><br>\n";
88 return @pg_numrows($result);
91 function da_sql_fetch_array($result,$config)
93 $row = @pg_fetch_array($result,$config[tmp_pg_array_num][$result]++,PGSQL_ASSOC);
94 if ($row && $config[sql_debug] == 'true'){
95 print "<b>DEBUG(SQL,PG DRIVER): Query Result: <pre>";
100 $config[tmp_pg_array_num][$result] = 0;
104 function da_sql_affected_rows($link,$result,$config)
106 if ($config[sql_debug] == 'true')
107 print "<b>DEBUG(SQL,PG DRIVER): Query Result: Affected rows:: " . @pg_cmdtuples($result) . "</b><br>\n";
108 return @pg_cmdtuples($result);
111 function da_sql_list_fields($table,$link,$config)
113 $res = @pg_query($link,
114 "select count(*) from pg_attribute where attnum > '0' and
115 attrelid = (select oid from pg_class where relname='$table');");
117 $row = @pg_fetch_row($res,0);
121 $fields[num] = $row[0];
124 $res = @pg_query($link,
125 "select attname from pg_attribute where attnum > '0' and
126 attrelid = (select oid from pg_class where relname='$table');");
135 function da_sql_num_fields($fields,$config)
141 function da_sql_field_name($fields,$num,$config)
144 $row = @pg_fetch_row($fields[res],$num);
150 function da_sql_error($link,$config)
152 return pg_errormessage($link);