Two methods of connecting sqlserver2000 in php5.3 (COM and ODBC) _php tutorial

Source: Internet
Author: User
Tags odbc connection
1.Com link, ADODB. Connection

Copy CodeThe code is as follows:
$conn = new Com ("ADODB. Connection "); Instantiate a Connection object
$connstr = "provider=sqloledb;datasource=.; Uid=sa;pwd=123456;database=jnold; ";
$conn->open ($CONNSTR);
$rs = new Com ("ADODB. Recordset "); Instantiate a RecordCount object

$rs->open (' select * from News where bigclassid = Leadpostil and "is null ', $conn, 1, 1);
$count = $rs->recordcount;
echo "Total {$count} records
";
for ($i = 0; $i < $count; $i + +) {

$arr _result[$i [' title '] = Addslashes ($rs->fields (' title ')->value);//title
$arr _result[$i [' Color '] = addslashes ($rs->fields (' Titlecolor ')->value? $rs->fields (' Titlecolor ') Value: ");//Title Color
$arr _result[$i] [' wenhao '] = addslashes ($rs->fields (' Othertext ')->value);//Text number

}


2.ODBC Connection MSSQL

Copy CodeThe code is as follows:
$dbhost = ";
$dbuser = "; Your MSSQL user name
$dbpass = "; Your MSSQL code.
$dbname = "; The name of your MSSQL library

$connect =odbc_connect ("Driver={sql Server}; server= $dbhost;D atabase= $dbname "," $dbuser "," $dbpass ");
$sql = "SELECT * from Content";
$exec =odbc_exec ($connect, $sql);
while ($row = (Odbc_fetch_array ($exec)))
{
$row [' ID ']//? Fetch field Value
...
}

http://www.bkjia.com/PHPjc/326416.html www.bkjia.com true http://www.bkjia.com/PHPjc/326416.html techarticle 1.Com Link, ADODB. The Connection copy code code is as follows: $conn = new Com ("ADODB"). Connection "); Instantiate a Connection object $connstr = "provider=sqloledb;datasource=.; Uid=sa;p ...

  • 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.