]>
git.defcon.no Git - hermes/blob - api/lib/db_functions.php
2aad11d0a213d2bb433c38dd3aad0deecad27924
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;
12 function sql_dbexec ( $db, $query )
14 if ( ! mysql_select_db( $db ) ) return false;
15 $result = mysql_query( $query );
16 if ( !$result ) return false;
19 function sql_dbquery_single( $db, $query )
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 );
27 function sql_dbtest_numrows ( $db, $query, $numrows )
29 $result = sql_dbquery( $db, $query );
31 if ( ! $result ) return false;
32 if ( mysql_num_rows($result) == $numrows ) return true;
35 function sql_dbexec_rows ( $db, $query )
37 if ( ! mysql_select_db( $db ) ) return false;
38 $result = mysql_query( $query );
39 if ( !$result ) return -1;
40 return mysql_affected_rows();
42 function sql_clean( $string )
44 return addslashes( $string );