We know that the new version of php5.3 is not supported by the MySQL mssql_connect this data connection function, if you need to connect SQL Server database, we can only use the COM interface to do OH.
1.Com link, ADODB. Connection
The code is as follows |
Copy Code |
$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
The code is as follows |
Copy Code |
$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/630732.html www.bkjia.com true http://www.bkjia.com/PHPjc/630732.html techarticle we know that the new version of php5.3 is not supported by the MySQL mssql_connect this data connection function, if you need to connect SQL Server database, we can only use the COM interface to do OH. 1.Com Chain ...