As for the PHP connection mssql2008 method can refer to my blog other articles will be introduced
Operation.
We can first read the download of the plugin inside the Help file, which is written in a very detailed unfortunately in English
You can also get the manual online, the Chinese is very convenient address is
http://technet.microsoft.com/zh-cn/library/hh352126 (sql.10). aspx
http://msdn.microsoft.com/zh-cn/library/hh352126 (v=sql.10). aspx
Below is a simple test that I wrote
Basic functions are available.
Includes connection to SQL Access records and content access to fields and content.
php-sql2008
$serverName = "(local)"; Resource Repository server address
$uid = "sa"; User name of the information repository
$pwd = "Admin777"; Information repository Password
$db _name= "Db_fmdisp"; Resource Name
$connectionInfo = Array ("UID" = = $uid, "PWD" = = $pwd, "Database" = $db _name);
$conn = Sqlsrv_connect ($serverName, $connectionInfo);
if ($conn = = False)
{
echo "Connect error! ";
Die (Print_r (Sqlsrv_errors (), true));
}
Execute SQL sentence
$stmt = sqlsrv_query ($conn, "select TOP [uid],[uname],[upwd],[udate],[enable] from [db_fmdisp].[ DBO]. [Tb_user] ", Array (), Array (" scrollable "= Sqlsrv_cursor_keyset));
if ($stmt = = = False)
{
echo "Error in executing query.
";
Die (Print_r (Sqlsrv_errors (), true));
}
Access to records
$row _count = sqlsrv_num_rows ($stmt);
if ($row _count = = = False) {
echo "\nget row error\n".
';
Print_r (Sqlsrv_errors (), true);
}
else if ($row _count >=0) {
Echo ' line: '. \n$row_count\n "."
';
}
Get columns
$field _count = Sqlsrv_num_fields ($stmt);
if ($field _count = = = False) {
echo "\nget row error\n".
';
Print_r (Sqlsrv_errors (), true);
}
else if ($field _count >=0) {
echo ' column: '. ' \n$field_count\n "."
';
}
Gain access to a column of records (in digital terms)
/* Make the first row of the result set available for reading. */
if (sqlsrv_fetch ($stmt) = = = False)
{
echo "Error in retrieving row.\n";
Die (Print_r (Sqlsrv_errors (), true));
}
$name = Sqlsrv_get_field ($stmt, 0);
Echo ' content: '. ' $name: ". '
';
Show the data
Give the records to the numbers and show them (by the name of the column)
while ($row = Sqlsrv_fetch_array ($stmt)) {
echo $row [' uid ']. -----". $row [' uname ']." -----". $row [' upwd ']."
";
} www.2cto.com
/* FREE statement and connection resources. */
Sqlsrv_free_stmt ($stmt);
Sqlsrv_close ($conn);
?>
Common SQL sentences
$stmt = sqlsrv_query ($conn, "INSERT into DB_FMDISP.dbo.tb_user (uname,upwd,udate,enable) VALUES (' name ', ' pwd ', ' 2010-10-10 10:10:00 ', 1) ");
$stmt = sqlsrv_query ($conn, "select * from DB_FMDISP.dbo.tb_user");
API reference (SQL Server Driver for PHP)
The API name for the SQL Server Driver for PHP is sqlsrv. All sqlsrv functions begin with sqlsrv_ , followed by verbs or nouns. A function followed by a verb is used to perform a specific operation, followed by a function of a noun to return a particular form of metadata.
SQL Server Driver for PHP contains the following functions:
| Function |
Description |
| Sqlsrv_begin_transaction |
Begins a transaction. |
| Sqlsrv_cancel |
Cancels the statement and discards all pending results for the corresponding statement. |
| Sqlsrv_client_info |
Provides information about the client. |
| Sqlsrv_close |
Close the connection. Frees all resources associated with the corresponding connection. |
| Sqlsrv_commit |
Commits the transaction. |
| Sqlsrv_configure |
Change the error handling and logging configuration. |
| Sqlsrv_connect |
Create a connection and open it. |
| Sqlsrv_errors |
Returns error and/or warning information about the previous action. |
| Sqlsrv_execute |
Executes a pre-defined statement. |
| Sqlsrv_fetch |
Makes the next row of data available for reading. |
| Sqlsrv_fetch_array |
Retrieves the data for the next row in the form of a numeric index array, an associative array, or both arrays. |
| Sqlsrv_fetch_object |
Retrieves the data for the next row as an object. |
| Sqlsrv_field_metadata |
Returns the field metadata. |
| Sqlsrv_free_stmt |
Close the statement. Frees all resources associated with the corresponding statement. |
| Sqlsrv_get_config |
Returns the value of the specified configuration setting. |
| Sqlsrv_get_field |
Retrieves the fields in the current row by index. You can specify the PHP return type. |
| Sqlsrv_has_rows |
Detects whether the result set has one or more rows. |
| Sqlsrv_next_result |
Make the next result available for processing. |
| Sqlsrv_num_rows |
The number of rows in the report result set. |
| Sqlsrv_num_fields |
Retrieves the number of fields in the active result set. |
| Sqlsrv_prepare |
Prepares a Transact-SQL query , but does not execute the query. An implicit binding parameter. |
| Sqlsrv_query |
Prepares a Transact-SQL query and executes it. |
| Sqlsrv_rollback |
Rolls back the transaction. |
| sqlsrv_rows_affected |
Returns the number of rows that have been modified. |
| Sqlsrv_send_stream_data |
Sends a maximum of 8,000 bytes (8 KB) of data to the server each time the function is called. |
| Sqlsrv_server_info |
Provides information about the server. |
Excerpt from: The Power of concentration
http://www.bkjia.com/PHPjc/478602.html www.bkjia.com true http://www.bkjia.com/PHPjc/478602.html techarticle As for the PHP connection mssql2008 method can refer to the other articles of my blog will have the introduction of the operation, we can first read the download of the plugin inside the Help file, which is written in a very detailed pity is ...