<?php

function connectDb()
{
	$conn=mssql_connect('localhost','sa','123456');
	mssql_select_db('HotelGXIF',$conn) or die(mssql_get_last_message());
	//mssql_query("set names 'GBK'");
	return $conn;
	//mysql_connect('localhost','root','cosin') or die('数据库链接失败');
	//mysql_select_db('imgsharedb') or die(mysql_error());
	//mysql_query('set names utf8') or die(mysql_error());//如果页面编码是utf-8的。这里设置查询的编码为utf-8
}

function querySql($sql)
{
	connectDb();
	$result = mssql_query($sql) or die(mssql_get_last_message());
	return $result;
}

function executeSql($sql)
{
	connectDb();
	//$sql = "select * from CompanyInfo where Code='0'";
	if(mssql_query($sql) or die(mssql_get_last_message()))
		return true;
	else
		return false;
}

function freeResult($result)
{
	mssql_free_result($result);
}

function closeDb()
{
	mssql_close();
}

function getRecordCount($sql)
{
	$result = querySql($sql);
	$row = mssql_fetch_array($result);
	$res = $row['count'];
	freeResult($result);
	return $res;
}

function fetch_array()
{
	mssql_fetch_array();
}

//function getLastInsertId()
//{
//	return mssql_insert_id();
//}

?>