]> git.defcon.no Git - hermes/blob - api/lib/db_functions.php
Changed sql_dbquery to return result on zero rows. Resulted in some patchings. Added...
[hermes] / api / lib / db_functions.php
1 <?php
2 require_once('config.php');
3 require_once('lib/common_functions.php');
4
5 function sql_dbquery( $db, $query )
6 {
7 if ( ! mysql_select_db( $db ) ) return false;
8 $result = mysql_query( $query );
9 if ( !$result ) return false;
10 return $result;
11 }
12 function sql_dbexec ( $db, $query )
13 {
14 if ( ! mysql_select_db( $db ) ) return false;
15 $result = mysql_query( $query );
16 if ( !$result ) return false;
17 return $result;
18 }
19 function sql_dbquery_single( $db, $query )
20 {
21 $result = sql_dbquery( $db, $query );
22 if ( ! $result ) return false;
23 if ( mysql_num_rows($result) != 1) return false;
24 $data = mysql_fetch_assoc( $result );
25 return $data;
26 }
27 function sql_dbtest_numrows ( $db, $query, $numrows )
28 {
29 $result = sql_dbquery( $db, $query );
30
31 if ( ! $result ) return false;
32 if ( mysql_num_rows($result) == $numrows ) return true;
33 return false;
34 }
35 function sql_dbexec_rows ( $db, $query )
36 {
37 if ( ! mysql_select_db( $db ) ) return false;
38 $result = mysql_query( $query );
39 if ( !$result ) return -1;
40 return mysql_affected_rows();
41 }
42 function sql_clean( $string )
43 {
44 return addslashes( $string );
45 }
46
47
48 ?>