Made it 2.0.0, and removed the changes that are in 1.1.x, as
[freeradius.git] / dialup_admin / lib / sql / drivers / mysql / functions.php3
1 <?php
2 function da_sql_limit($limit,$point,$config)
3 {
4         switch($point){
5                 case 0:
6                         return '';
7                 case 1:
8                         return '';
9                 case 3:
10                         return "LIMIT $limit";
11         }
12 }
13
14 function da_sql_host_connect($server,$config)
15 {
16         if ($config[sql_use_http_credentials] == 'yes'){
17                 global $HTTP_SERVER_VARS;
18                 $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
19                 $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
20         }
21         else{
22                 $SQL_user = $config[sql_username];
23                 $SQL_passwd = $config[sql_password];
24         }
25
26         if ($config[sql_connect_timeout] != 0)
27                 @ini_set('mysql.connect_timeout',$config[sql_connect_timeout]);
28         if ($config[sql_debug] == 'true')
29                 print "<b>DEBUG(SQL,MYSQL DRIVER): Connect: User=$SQL_user,Password=$SQL_passwd </b><br>\n";
30         return @mysql_connect("$server:$config[sql_port]",$SQL_user,$SQL_passwd);
31 }
32
33 function da_sql_connect($config)
34 {
35         if ($config[sql_use_http_credentials] == 'yes'){
36                 global $HTTP_SERVER_VARS;
37                 $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
38                 $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
39         }
40         else{
41                 $SQL_user = $config[sql_username];
42                 $SQL_passwd = $config[sql_password];
43         }
44
45         if ($config[sql_connect_timeout] != 0)
46                 @ini_set('mysql.connect_timeout',$config[sql_connect_timeout]);
47         if ($config[sql_debug] == 'true')
48                 print "<b>DEBUG(SQL,MYSQL DRIVER): Connect: User=$SQL_user,Password=$SQL_passwd </b><br>\n";
49         return @mysql_connect("$config[sql_server]:$config[sql_port]",$SQL_user,$SQL_passwd);
50 }
51
52 function da_sql_pconnect($config)
53 {
54         if ($config[sql_use_http_credentials] == 'yes'){
55                 global $HTTP_SERVER_VARS;
56                 $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
57                 $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
58         }
59         else{
60                 $SQL_user = $config[sql_username];
61                 $SQL_passwd = $config[sql_password];
62         }
63
64         if ($config[sql_connect_timeout] != 0)
65                 @ini_set('mysql.connect_timeout',$config[sql_connect_timeout]);
66         if ($config[sql_debug] == 'true')
67                 print "<b>DEBUG(SQL,MYSQL DRIVER): Connect: User=$SQL_user,Password=$SQL_passwd </b><br>\n";
68         return @mysql_pconnect("$config[sql_server]:$config[sql_port]",$SQL_user,$SQL_passwd);
69 }
70
71 function da_sql_close($link,$config)
72 {
73         return @mysql_close($link);
74 }
75
76 function da_sql_escape_string($string)
77 {
78         return @mysql_escape_string($string);
79 }
80
81 function da_sql_query($link,$config,$query)
82 {
83         if ($config[sql_debug] == 'true')
84                 print "<b>DEBUG(SQL,MYSQL DRIVER): Query: <i>$query</i></b><br>\n";
85         return @mysql_db_query($config[sql_database],$query,$link);
86 }
87
88 function da_sql_num_rows($result,$config)
89 {
90         if ($config[sql_debug] == 'true')
91                 print "<b>DEBUG(SQL,MYSQL DRIVER): Query Result: Num rows:: " . @mysql_num_rows($result) . "</b><br>\n";
92         return @mysql_num_rows($result);
93 }
94
95 function da_sql_fetch_array($result,$config)
96 {
97         $row = array_change_key_case(@mysql_fetch_array($result,
98                 MYSQL_ASSOC),CASE_LOWER);
99         if ($config[sql_debug] == 'true'){
100                 print "<b>DEBUG(SQL,MYSQL DRIVER): Query Result: <pre>";
101                 print_r($row);
102                 print "</b></pre>\n";
103         }
104         return $row;
105 }
106
107 function da_sql_affected_rows($link,$result,$config)
108 {
109         if ($config[sql_debug] == 'true')
110                 print "<b>DEBUG(SQL,MYSQL DRIVER): Query Result: Affected rows:: " . @mysql_affected_rows($result) . "</b><br>\n";
111         return @mysql_affected_rows($link);
112 }
113
114 function da_sql_list_fields($table,$link,$config)
115 {
116         return @mysql_list_fields($config[sql_database],$table);
117 }
118
119 function da_sql_num_fields($fields,$config)
120 {
121         return @mysql_num_fields($fields);
122 }
123
124 function da_sql_field_name($fields,$num,$config)
125 {
126         return @mysql_field_name($fields,$num);
127 }
128
129 function da_sql_error($link,$config)
130 {
131         return @mysql_error($link);
132 }
133 ?>