00001 <?php
00011 class DB_ODBC extends DB_Base
00012 {
00013 function DB_ODBC($conn, $persistent) {
00014 $this->safesql = new SafeSQL_ANSI;
00015 $this->type = 'odbc';
00016
00017 $this->conn = odbc_connect("DRIVER=FreeTDS;SERVER=".$conn['host'].";DATABASE=".$conn['name'], $conn['user'], $conn['pass']);
00018 if(!$this->conn) {
00019 $this->_catch("Unable to connect to the database!");
00020 return false;
00021 }
00022 return true;
00023 }
00024
00025 function _catch($msg="") {
00026 if(!$this->error = odbc_errormsg($this->conn)) return true;
00027 $this->error($msg."<br>{$this->query} \n {$this->error}");
00028 }
00029
00030 function select($db) {
00031 }
00032
00033 function get_table_defn($table) {
00034 return false;
00035 }
00036
00037 function run_query($sql) {
00038 return odbc_exec($sql, $this->conn);
00039 }
00040
00041 function fetch_row(&$q) {
00042 return odbc_fetch_row($q);
00043 }
00044
00045 function fetch_array(&$q) {
00046 return odbc_fetch_array($q);
00047 }
00048
00049 function fetch_field(&$q, $num) {
00050 return odbc_field_name($q, $num);
00051 }
00052
00053 function num_fields(&$q) {
00054 return odbc_num_fields($q);
00055 }
00056
00057 function num_orws(&$q) {
00058 return odbc_num_rows($q);
00059 }
00060
00061 function get_insert_id() {
00062 $r = odbc_fetch_row(odbc_exec("select @@IDENTITY", $this->conn));
00063 return $r[0];
00064 }
00065
00066 function free_result($q) {
00067 return @odbc_free_result($q);
00068 }
00069 }
00070
00071 ?>