Php5.3 how to connect to sqlserver2000. We know that the new version of php5.3 does not support the data connection function mssql_connect provided by mysql. to connect to the sqlserver database, we can only use the com interface. 1. we know that the new version of php5.3 does not support the data connection function mssql_connect provided by mysql. to connect to the sqlserver database, we can only use the Com interface.
1. Com link, ADODB. Connection
| The 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 = 59 And LeadPostil is Null', $ conn, 1, 1 );
$ Count = $ rs-> RecordCount;
Echo "a total of {$ 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); // Document No.
} |
2. ODBC Connection mssql
| The code is as follows: |
|
|
$ Dbhost = ";
$ Dbuser = "; // your mssql user name
$ Dbpass = "; // your mssql password
$ Dbname = "; // your mssql database name
$ Connect = odbc_connect ("Driver = {SQL Server}; Server = $ dbhost; Database = $ dbname", "$ dbuser", "$ dbpass ");
$ SQL = "select * from content ";
$ Exec = odbc_exec ($ connect, $ SQL );
While ($ row = (odbc_fetch_array ($ exec )))
{
$ Row ['id'] //? Field value
...
} |
You can use the DIG Interface. 1. Com chain...