]>
git.defcon.no Git - hermes/blob - api/lib/db_functions.php
6ec0f53766dea32ae5c691619ff6a67088dfa6c4
2 require_once('config.php');
3 require_once('lib/common_functions.php');
5 function sql_dbquery( $db, $query )
7 if ( ! mysql_select_db( $db ) ) return false;
8 $result = mysql_query( $query );
9 if ( !$result ) return false;
10 if (mysql_num_rows($result) == 0) return false;
13 function sql_dbexec ( $db, $query )
15 if ( ! mysql_select_db( $db ) ) return false;
16 $result = mysql_query( $query );
17 if ( !$result ) return false;
20 function sql_dbquery_single( $db, $query )
22 $result = sql_dbquery( $db, $query );
23 if ( ! $result ) return false;
24 if ( mysql_num_rows($result) != 1) return false;
25 $data = mysql_fetch_assoc( $result );
28 function sql_dbtest_numrows ( $db, $query, $numrows )
30 $result = sql_dbquery( $db, $query );
32 if ( ! $result ) return false;
33 if ( mysql_num_rows($result) == $numrows ) return true;
36 function sql_dbexec_rows ( $db, $query )
38 if ( ! mysql_select_db( $db ) ) return false;
39 $result = mysql_query( $query );
40 if ( !$result ) return -1;
41 return mysql_affected_rows();
43 function sql_clean( $string )
45 return addslashes( $string );