. See AUTHORS to learn who helped make it become a reality. */#### #### #### #### #### #### #### #### #### #### /* SQL_CURSOR_TYPE (integer) SQL_CURSOR_FORWARD_ONLY (integer) SQL_CURSOR_KEYSET_DRIVEN (integer) SQL_CURSOR_DYNAMIC (integer) SQL_CURSOR_STATIC (integer) */ /* * This file contains the function for database connection * via odbc */ // Converter function dbc_sql_timeformat($timestamp) { //use '#' for MS Access //return "#".date("Y-m-d H:i:s", $timestamp)."#"; //return "#".date("m/d/Y H:i:s", $timestamp)."#"; return "{ ts '".date("Y-m-d H:i:s", $timestamp)."' }"; } // Driver function db_connection() { return odbc_connect(_DBNAME, _DBUSERID, _DBPWD, SQL_CUR_USE_ODBC); } function db_own_connection($host, $port, $user, $pass, $dbname) { $db = odbc_connect($dbname, $user, $pass, SQL_CUR_USE_ODBC) or db_die_with_error(_MSGNoDBCon); return $db; } function db_exec($db, $cmdSQL) { // echo "

" . $cmdSQL . "

"; return odbc_exec($db, $cmdSQL); } function db_num_rows($res) { return odbc_num_rows($res); } function db_fetch_row($res) { return odbc_fetch_row($res); } function db_fetch_singleresult($res) { return odbc_fetch_array($res); } function db_fetch_array($res) { //odbc_fetch_into replaced odbc_fetch_array, because //in various php version the fetch_array doesnt work //odbc_fetch_into($res, $myarray); odbc_fetch_into($res, $myarray); return $myarray; } function db_result($res, $res_name) { return odbc_result($res, $res_name); } function db_close($db) { odbc_close($db); } function db_num_count($cmdSQLwhere_part) { return 'SELECT DISTINCT COUNT(*) AS num FROM ' . _DBTABLENAME . substr($cmdSQLwhere_part, 0, strpos($cmdSQLwhere_part, 'ORDER BY')); } /* * fetch a result row as an a numeric array, * the array points to the first data record you want to display * at current page. You need it for paging. */ function db_exec_limit($db, $cmdSQLfirst_part, $cmdSQLmain_part, $cmdSQLwhere_part, $limitlower, $perpage) { //you must move through the recordset //until you reach the data record you want //***if you know a better and more efficent methode, please let us know, too! $tmp = $perpage + $limitlower - 1; $cmdSQL = $cmdSQLfirst_part . "TOP " . $tmp . " " . $cmdSQLmain_part . $cmdSQLwhere_part; return db_exec($db, $cmdSQL); /* for($i = 1; $i < $limitlower; $i++) $row = odbc_fetch_row($result); return $result; */ } function db_free_result($result) { return odbc_free_result($result); } function db_errno() { return odbc_error(); } function db_error() { return odbc_errormsg(); } function db_die_with_error($MyErrorMsg) { $errdesc = odbc_errormsg(); $errno = odbc_error(); $errormsg="
Database error: $MyErrorMsg
"; $errormsg.="mysql error: $errdesc
"; $errormsg.="mysql error number: $errno
"; $errormsg.="Date: ".date("d.m.Y @ H:i")."
"; $errormsg.="Script: ".getenv("REQUEST_URI")."
"; $errormsg.="Referer: ".getenv("HTTP_REFERER")."

"; echo $errormsg; exit; } function db_get_wildcut() { return '%'; } ?>