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