PHP MSSQL Database Connection Class code (1/2)

Source: Internet
Author: User
Tags mssql php tutorial

PHP Tutorial MSSQL Database Tutorial Connection Class code

The code is as follows Copy Code

Class Db_sql {
var $Host = "";
var $Database = "";
var $User = "";
var $Password = "";

var $Link _id = 0;
var $Query _id = 0;
var $Record = array ();
var $Row = 0;

var $Errno = 0;
var $Error = "";

var $Auto _free = 0; # # Set this to 1 to automatically free results


* Public:constructorwww.111cn.net * *
function Db_sql ($query = "") {
$this->query ($query);
}

function Connect () {
if (0 = = $this->link_id) {
$this->link_id=mssql_connect ($this->host, $this->user, $this->password);
if (! $this->link_id)
$this->halt ("Link-id = = False, Mssql_pconnect failed");
Else
@mssql_select_db ($this->database, $this->link_id);
}
}
function Free_result () {
Mssql_free_result ($this->query_id);
$this->query_id = 0;
}

function query ($Query _string)
{

/* No empty queries, please, since PHP4 chokes on them. */
if ($Query _string = "")
/* The empty query string is passed on from the constructor,
* When calling the class without a query, e.g. in situations
* like: ' $db = new Db_sql_subclass; '
*/
return 0;

if (! $this->link_id)
$this->connect ();

# printf ("<br>debug:query =%s<br>", $Query _string);

Home 1 2 last page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.