Subversion Repositories ALCASAR

Rev

Rev 1831 | Rev 2488 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
325 richard 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
//modif by MG for Alcasar
10
		case 2:
11
			return "LIMIT $limit";
12
		case 3:
13
			return "LIMIT $limit";
14
	}
15
}
16
 
17
function da_sql_host_connect($server,$config)
18
{
1805 clement.si 19
	if ($config['sql_use_http_credentials'] == 'yes'){
325 richard 20
		global $HTTP_SERVER_VARS;
21
		$SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
22
		$SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
23
	}
24
	else{
1805 clement.si 25
		$SQL_user = $config['sql_username'];
26
		$SQL_passwd = $config['sql_password'];
325 richard 27
	}
28
 
1805 clement.si 29
	if ($config['sql_connect_timeout'] != 0)
30
		ini_set('mysql.connect_timeout',$config['sql_connect_timeout']);
31
	if ($config['sql_debug'] == 'true')
325 richard 32
		print "<b>DEBUG(SQL,MYSQL DRIVER): Connect: User=$SQL_user,Password=$SQL_passwd </b><br>\n";
1805 clement.si 33
	return mysqli_connect("$server:$config[sql_port]",$SQL_user,$SQL_passwd,$config['sql_database']);
325 richard 34
}
35
 
36
function da_sql_connect($config)
37
{
1805 clement.si 38
	if (isset($config['sql_use_http_credentials']) && $config['sql_use_http_credentials'] == 'yes'){
325 richard 39
		global $HTTP_SERVER_VARS;
40
		$SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
41
		$SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
42
	}
43
	else{
1805 clement.si 44
		$SQL_user = $config['sql_username'];
45
		$SQL_passwd = $config['sql_password'];
325 richard 46
	}
47
 
1805 clement.si 48
	if ($config['sql_connect_timeout'] != 0)
49
		ini_set('mysql.connect_timeout',$config['sql_connect_timeout']);
50
	if ($config['sql_debug'] == 'true')
325 richard 51
		print "<b>DEBUG(SQL,MYSQL DRIVER): Connect: User=$SQL_user,Password=$SQL_passwd </b><br>\n";
1805 clement.si 52
	return mysqli_connect("$config[sql_server]:$config[sql_port]",$SQL_user,$SQL_passwd,$config['sql_database']);
325 richard 53
}
54
 
55
function da_sql_pconnect($config)
56
{
1805 clement.si 57
	if (isset($config['sql_use_http_credentials']) && $config['sql_use_http_credentials'] == 'yes'){
325 richard 58
		global $HTTP_SERVER_VARS;
59
		$SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
60
		$SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
61
	}
62
	else{
1805 clement.si 63
		$SQL_user = $config['sql_username'];
64
		$SQL_passwd = $config['sql_password'];
325 richard 65
	}
1805 clement.si 66
	if ($config['sql_connect_timeout'] != 0)
67
		ini_set('mysql.connect_timeout',$config['sql_connect_timeout']);
68
	if ($config['sql_debug'] == 'true')
325 richard 69
		print "<b>DEBUG(SQL,MYSQL DRIVER): Connect: User=$SQL_user,Password=$SQL_passwd </b><br>\n";
1805 clement.si 70
	return mysqli_connect($config['sql_server'],$SQL_user,$SQL_passwd,$config['sql_database'],$config['sql_port']);
325 richard 71
}
72
 
73
function da_sql_close($link,$config)
74
{
1805 clement.si 75
	return mysqli_close($link);
325 richard 76
}
77
 
1805 clement.si 78
function da_sql_escape_string($link, $string)
325 richard 79
{
1805 clement.si 80
	return mysqli_real_escape_string($link, $string);
325 richard 81
}
82
 
83
function da_sql_query($link,$config,$query)
84
{
1805 clement.si 85
	if ($config['sql_debug'] == 'true')
325 richard 86
		print "<b>DEBUG(SQL,MYSQL DRIVER): Query: <i>$query</i></b><br>\n";
1805 clement.si 87
	return mysqli_query($link,$query);
325 richard 88
}
89
 
90
function da_sql_num_rows($result,$config)
91
{
1805 clement.si 92
	if ($config['sql_debug'] == 'true')
93
		print "<b>DEBUG(SQL,MYSQL DRIVER): Query Result: Num rows:: " . mysqli_num_rows($result) . "</b><br>\n";
94
	return mysqli_num_rows($result);
325 richard 95
}
96
 
97
function da_sql_fetch_array($result,$config)
98
{
1805 clement.si 99
	$row = @array_change_key_case(mysqli_fetch_array($result,
100
		MYSQLI_ASSOC),CASE_LOWER);
101
	if ($config['sql_debug'] == 'true'){
325 richard 102
		print "<b>DEBUG(SQL,MYSQL DRIVER): Query Result: <pre>";
103
		print_r($row);
104
		print "</b></pre>\n";
105
	}
106
	return $row;
107
}
108
 
109
function da_sql_affected_rows($link,$result,$config)
110
{
1805 clement.si 111
	if ($config['sql_debug'] == 'true')
112
		print "<b>DEBUG(SQL,MYSQL DRIVER): Query Result: Affected rows:: " . mysqli_affected_rows($result) . "</b><br>\n";
113
	return mysqli_affected_rows($link);
325 richard 114
}
115
 
116
function da_sql_list_fields($table,$link,$config)
117
{
1805 clement.si 118
	return da_sql_query($link, $config, "SHOW COLUMNS FROM $table");
325 richard 119
}
120
 
121
 
122
function da_sql_field_name($fields,$num,$config)
123
{
1805 clement.si 124
	return mysqli_fetch_field_direct($fields,$num);
325 richard 125
}
126
 
127
function da_sql_error($link,$config)
128
{
1805 clement.si 129
	return mysqli_error($link);
325 richard 130
}
131
?>