Index: doc-base/entities/global.ent
===================================================================
--- doc-base/entities/global.ent (revision 311900)
+++ doc-base/entities/global.ent (working copy)
@@ -52,7 +52,7 @@
-
+
@@ -632,6 +632,16 @@
+
+
+
+
+
+
+
+
+
+
Index: doc-base/manual.xml.in
===================================================================
--- doc-base/manual.xml.in (revision 311900)
+++ doc-base/manual.xml.in (working copy)
@@ -246,6 +246,7 @@
&reference.pgsql.book;
&reference.sqlite.book;
&reference.sqlite3.book;
+ &reference.sqlsrv.book;
&reference.sybase.book;
&reference.tokyo-tyrant.book;
Property changes on: en\reference\sqlsrv
___________________________________________________________________
Added: tsvn:projectlanguage
+ 1033
Added: bugtraq:number
+ true
Index: en/reference/sqlsrv/book.xml
===================================================================
--- en/reference/sqlsrv/book.xml (revision 0)
+++ en/reference/sqlsrv/book.xml (revision 0)
@@ -0,0 +1,46 @@
+
+
+
+
+ Microsoft SQL Server Driver for PHP
+
+
+
+
+ &reftitle.intro;
+
+ These functions allow you to access MS SQL Server databases when running PHP on Windows.
+
+
+ The SQLSRV extension is supported by Microsoft and available for download here: &url.sqlsrv;.
+
+
+
+
+
+ &reference.sqlsrv.reference;
+
+
+
+
+
Index: en/reference/sqlsrv/configure.xml
===================================================================
--- en/reference/sqlsrv/configure.xml (revision 0)
+++ en/reference/sqlsrv/configure.xml (revision 0)
@@ -0,0 +1,33 @@
+
+
+
+ &reftitle.install;
+
+ The SQLSRV extension is enabled by adding appropriate DLL file to your PHP extension directory and the corresponding entry to the
+ &php.ini; file.
+
+
+ The SQLSRV extension is only compatible with PHP running on Windows.
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/constants.xml
===================================================================
--- en/reference/sqlsrv/constants.xml (revision 0)
+++ en/reference/sqlsrv/constants.xml (revision 0)
@@ -0,0 +1,889 @@
+
+
+
+ &reftitle.constants;
+ &extension.constants;
+ This is a test.
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/entities.functions.xml
===================================================================
Property changes on: en\reference\sqlsrv\functions
___________________________________________________________________
Added: tsvn:projectlanguage
+ 1033
Added: bugtraq:number
+ true
Index: en/reference/sqlsrv/functions/sqlsrv-begin-transaction.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-begin-transaction.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-begin-transaction.xml (revision 0)
@@ -0,0 +1,135 @@
+
+
+
+
+ sqlsrv_begin_transaction
+ Begins a database transaction.
+
+
+ &reftitle.description;
+
+ boolsqlsrv_begin_transaction
+ resourceconn
+
+
+ The transaction that is begun includes all statements that were executed after the call to sqlsrv_begin_transaction and before calls to sqlsrv_rollback or sqlsrv_commit.
+ Explicit transactions should be started and committed or rolled back using these functions instead of executing SQL statements that begin and committ/roll back transactions.
+ For more information, see SQLSRV Transactions.
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-cancel.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-cancel.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-cancel.xml (revision 0)
@@ -0,0 +1,127 @@
+
+
+
+
+ sqlsrv_cancel
+ Cancels a statement.
+
+
+ &reftitle.description;
+
+ boolsqlsrv_cancel
+ resourcestmt
+
+
+ Cancels a statement. Any results associated with the statement that have not been consumed are deleted.
+ After sqlsrv_cancel has been called, the specified statement can be re-executed if it was created with sqlsrv_prepare.
+ Calling sqlsrv_cancel is not necessary if all the results associated with the statement have been consumed.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ stmt
+
+
+ The statement resource to be cancelled.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ &return.success;
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_cancel example
+
+"dbName", "UID"=>"username", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$tsql = "SELECT Sales FROM Table_1";
+$stmt = sqlsrv_prepare( $conn, $tsql);
+if( $stmt === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+if( sqlsrv_execute( $stmt ) === false) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$salesTotal = 0;
+$count = 0;
+
+while( ($row = sqlsrv_fetch_array( $stmt)) && $salesTotal <=100000)
+{
+ $qty = $row[0];
+ $price = $row[1];
+ $salesTotal += ( $price * $qty);
+ $count++;
+}
+echo "$count sales accounted for the first $$salesTotal in revenue.\n";
+
+/* Cancel the pending results. The statement can be reused. */
+sqlsrv_cancel( $stmt);
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.notes;
+
+ The main difference between sqlsrv_cancel and sqlsrv_free_stmt is that a statement resource cancelled with sqlsrv_cancel can be re-executed if it was created with sqlsrv_prepare.
+ A statement resource cancelled with sqlsrv_free_statement cannot be re-executed.
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_free_stmt
+ sqlsrv_prepare
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-client-info.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-client-info.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-client-info.xml (revision 0)
@@ -0,0 +1,130 @@
+
+
+
+
+ sqlsrv_client_info
+ Returns information about the client and specified connection.
+
+
+ &reftitle.description;
+
+ arraysqlsrv_client_info
+ resourceconn
+
+
+ Returns information about the client and specified connection
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ conn
+
+
+ The connection about which information is returned.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ On success, returns an associative array with the following keys:
+
+ Array returned by sqlsrv_client_info
+
+
+
+ Key
+ Description
+
+
+
+
+ DriverDllName
+ SQLNCLI10.DLL
+
+
+ DriverODBCVer
+ ODBC version (xx.yy)
+
+
+ DriverVer
+ SQL Server Native Client DLL version (10.5.xxx)
+
+
+ ExtensionVer
+ php_sqlsrv.dll version (2.0.xxx.x)
+
+
+
+
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_client_info example
+
+"username", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connOptions );
+
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+if( $client_info = sqlsrv_client_info( $conn)) {
+ foreach( $client_info as $key => $value) {
+ echo $key.": ".$value." ";
+ }
+} else {
+ echo "Error in retrieving client info. ";
+}
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_server_info
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-close.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-close.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-close.xml (revision 0)
@@ -0,0 +1,99 @@
+
+
+
+
+ sqlsrv_close
+ Closes an open connection and releases resourses associated with the connection.
+
+
+ &reftitle.description;
+
+ boolsqlsrv_close
+ resourceconn
+
+
+ Closes an open connection and releases resourses associated with the connection.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ conn
+
+
+ The connection to be closed.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ &return.success;
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_close example
+
+"username", "PWD"=>"password", "Database"=>"dbname");
+$conn = sqlsrv_connect( $serverName, $connOptions );
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+//-------------------------------------
+// Perform database operations here.
+//-------------------------------------
+
+// Close the connection.
+sqlsrv_close( $conn );
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_connect
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-commit.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-commit.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-commit.xml (revision 0)
@@ -0,0 +1,130 @@
+
+
+
+
+ sqlsrv_commit
+ Commit a transaction that was begun with sqlsrv_begin_transaction.
+
+
+ &reftitle.description;
+
+ boolsqlsrv_commit
+ resourceconn
+
+
+ Commits a transaction that was begun with sqlsrv_begin_transaction. The connection is returned to auto-commit mode after sqlsrv_commit is called.
+ The transaction that is committed includes all statements that were executed after the call to sqlsrv_begin_transaction.
+ Explicit transactions should be started and committed or rolled back using these functions instead of executing SQL statements that begin and committ/roll back transactions.
+ For more information, see SQLSRV Transactions.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ conn
+
+
+ The connection on which the transaction is to be committed.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ &return.success;
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_commit example
+
+ The following example demonstrates how to use sqlsrv_commit together with sqlsrv_begin_transaction and sqlsrv_rollback.
+
+
+"dbName", "UID"=>"userName", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true ));
+}
+
+/* Begin the transaction. */
+if ( sqlsrv_begin_transaction( $conn ) === false ) {
+ die( print_r( sqlsrv_errors(), true ));
+}
+
+/* Initialize parameter values. */
+$orderId = 1; $qty = 10; $productId = 100;
+
+/* Set up and execute the first query. */
+$sql1 = "INSERT INTO OrdersTable (ID, Quantity, ProductID)
+ VALUES (?, ?, ?)";
+$params1 = array( $orderId, $qty, $productId );
+$stmt1 = sqlsrv_query( $conn, $sql1, $params1 );
+
+/* Set up and execute the second query. */
+$sql2 = "UPDATE InventoryTable
+ SET Quantity = (Quantity - ?)
+ WHERE ProductID = ?";
+$params2 = array($qty, $productId);
+$stmt2 = sqlsrv_query( $conn, $sql2, $params2 );
+
+/* If both queries were successful, commit the transaction. */
+/* Otherwise, rollback the transaction. */
+if( $stmt1 && $stmt2 ) {
+ sqlsrv_commit( $conn );
+ echo "Transaction committed. ";
+} else {
+ sqlsrv_rollback( $conn );
+ echo "Transaction rolled back. ";
+}
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_begin_transaction
+ sqlsrv_rollback
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-configure.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-configure.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-configure.xml (revision 0)
@@ -0,0 +1,105 @@
+
+
+
+
+ sqlsrv_configure
+ Change the driver error handling and logging configurations.
+
+
+ &reftitle.description;
+
+ boolsqlsrv_configure
+ stringsetting
+ mixedvalue
+
+
+ Changes the driver error handling and logging configurations.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ setting
+
+
+ The name of the setting to set. The possible values are "WarningsReturnAsErrors", "LogSubsystems", and "LogSeverity".
+
+
+
+
+ value
+
+
+ The value of the specified setting. The following table shows possible values:
+
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ &return.success;
+
+
+
+
+ &reftitle.seealso;
+
+
+ SQLSRV Error Handling.
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-connect.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-connect.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-connect.xml (revision 0)
@@ -0,0 +1,163 @@
+
+
+
+
+ sqlsrv_connect
+ Open a connection to a Microsoft SQL Server database.
+
+
+ &reftitle.description;
+
+ resourcesqlsrv_connect
+ stringserverName
+ arrayconnectionInfo
+
+
+ Opens a connection to a Microsoft SQL Server database. By default, the connection is attempted using Windows Authentication.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ serverName
+
+
+ The name of the server to which a connection is established. To connect to a specific instance, follow the server name with a forward slash and the instance name (e.g. serverName\sqlexpress).
+
+
+
+
+ connectionInfo
+
+
+ An associative array that specifies options for connecting to the server. If values for the UID and PWD keys are not specified, the connection will be attempted using Windows Authentication. For a complete list of keys, see SQLSRV Connection Options.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ A connection resource. If a connection cannot be successfully opened, false is returned.
+
+
+
+
+ &reftitle.examples;
+
+
+ Connect using Windows Authentication.
+
+"dbName");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+
+if( $conn ) {
+ echo "Connection established. ";
+}else{
+ echo "Connection could not be established. ";
+ die( print_r( sqlsrv_errors(), true));
+}
+?>
+]]>
+
+
+
+
+
+ Connect by specifying a user name and password.
+
+"dbName", "UID"=>"userName", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+
+if( $conn ) {
+ echo "Connection established. ";
+}else{
+ echo "Connection could not be established. ";
+ die( print_r( sqlsrv_errors(), true));
+}
+?>
+]]>
+
+
+
+
+
+ Connect on a specifed port.
+
+"dbName", "UID"=>"userName", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+
+if( $conn ) {
+ echo "Connection established. ";
+}else{
+ echo "Connection could not be established. ";
+ die( print_r( sqlsrv_errors(), true));
+}
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.notes;
+
+ By default, the SQLSRV uses connection pooling to improve connection performance. For more information, see SQLSRV Connection Pooling.
+
+
+ The SQLSRV does not have a dedicated function for changing which database is connected to. The target database is specified in the $connectionOptions array that is passed to sqlsrv_connect.
+ To change the database on an open connection, execute the following query "USE dbName" (e.g. sqlsrv_query($conn, "USE dbName")).
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_close
+ sqlsrv_errors
+ sqlsrv_query
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-errors.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-errors.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-errors.xml (revision 0)
@@ -0,0 +1,150 @@
+
+
+
+
+ sqlsrv_errors
+ Return error and warning information about the last sqlsrv operation performed.
+
+
+ &reftitle.description;
+
+
+ mixedsqlsrv_errors
+ interrorsOrWarnings
+
+
+ Returns error and warning information about the last sqlsrv operation performed.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ errorsOrWarnings
+
+
+ Determines whether error information, warning information, or both are returned. If this parameter is not supplied, both error information and warning information are returned.
+ The following are the accepted values for this parameter: SQLSRV_ERR_ALL, SQLSRV_ERR_ERRORS, SQLSRV_ERR_WARNINGS.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ If errors and/or warnings occured on the last sqlsrv operation, and array of arrays containing error information is returned. If no errors and/or warnings occured on the last sqlsrv operation, NULL is returned.
+ The following table describes the structure of the returned arrays:
+
+ Array returned by sqlsrv_errors
+
+
+
+ Key
+ Description
+
+
+
+
+ SQLSTATE
+ For errors that originate from the ODBC driver, the SQLSTATE returned by ODBC.
+ For errors that originate from the Microsoft Drivers for PHP for SQL Server, a SQLSTATE of IMSSP.
+ For warnings that originate from the Microsoft Drivers for PHP for SQL Server, a SQLSTATE of 01SSP.
+
+
+
+ code
+ For errors that originate from SQL Server, the native SQL Server error code.
+ For errors that originate from the ODBC driver, the error code returned by ODBC.
+ For errors that originate from the Microsoft Drivers for PHP for SQL Server, the Microsoft Drivers for PHP for SQL Server error code.
+
+
+
+ message
+ A description of the error.
+
+
+
+
+
+
+
+
+ &reftitle.examples;
+
+
+ functionname example
+
+"dbName", "UID"=>"username", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+/* Set up a query to select an invalid column name. */
+$sql = "SELECT BadColumnName FROM Table_1";
+
+/* Execution of the query will fail because of the bad column name. */
+$stmt = sqlsrv_query( $conn, $sql );
+if( $stmt === false ) {
+ if( ($errors = sqlsrv_errors() ) != null) {
+ foreach( $errors as $error ) {
+ echo "SQLSTATE: ".$error[ 'SQLSTATE']." ";
+ echo "code: ".$error[ 'code']." ";
+ echo "message: ".$error[ 'message']." ";
+ }
+ }
+}
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.notes;
+
+ By default, warnings generated on a call to any sqlsrv function are treated as errors; if a warning occurs on a call to a sqlsrv function, the function returns false.
+ However, warnings that correspond to SQLSTATE values 01000, 01001, 01003, and 01S02 are never treated as errors.
+ For information about changing this behavior, see sqlsrv_configure and the WarningsReturnAsErrors setting.
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_configure
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-execute.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-execute.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-execute.xml (revision 0)
@@ -0,0 +1,130 @@
+
+
+
+
+ sqlsrv_execute
+ Execute a statement prepared with sqlsrv_prepare.
+
+
+ &reftitle.description;
+
+ boolsqlsrv_execute
+ resourcestmt
+
+
+ Executes a statement prepared with sqlsrv_prepare. This function is ideal for executing a prepared statement multiple times with different parameter values.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ stmt
+
+
+ A statement resourse returned by sqlsrv_prepare.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ &return.success;
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_execute example
+
+ This example demonstrates how to prepare a statement with sqlsrv_prepare and re-execute it multiple times (with different parameter values) using sqlsrv_execute.
+
+
+"dbName", "UID"=>"username", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+if( $conn === false) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$sql = "UPDATE Table_1
+ SET OrderQty = ?
+ WHERE SalesOrderID = ?";
+
+// Initialize parameters and prepare the statement.
+// Variables $qty and $id are bound to the statement, $stmt.
+$qty = 0; $id = 0;
+$stmt = sqlsrv_prepare( $conn, $sql, array( &$qty, &$id));
+if( !$stmt ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+// Set up the SalesOrderDetailID and OrderQty information.
+// This array maps the order ID to order quantity in key=>value pairs.
+$orders = array( 1=>10, 2=>20, 3=>30);
+
+// Execute the statement for each order.
+foreach( $orders as $id => $qty) {
+ // Because $id and $qty are bound to $stmt1, their updated
+ // values are used with each execution of the statement.
+ if( sqlsrv_execute( $stmt ) === false ) {
+ die( print_r( sqlsrv_errors(), true));
+ }
+}
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.notes;
+
+ When you prepare a statement that uses variables as parameters, the variables are bound to the statement.
+ This means that if you update the values of the variables, the next time you execute the statement it will run with updated parameter values.
+ For statements that you plan to execute only once, use sqlsrv_query.
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_prepare
+ sqlsrv_query
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-fetch-array.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-fetch-array.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-fetch-array.xml (revision 0)
@@ -0,0 +1,171 @@
+
+
+
+
+ sqlsrv_fetch_array
+ Returns a row as an array.
+
+
+ &reftitle.description;
+
+ arraysqlsrv_fetch_array
+ resourcestmt
+ intfetchType
+ introw
+ intoffset
+
+
+ Returns the next available row of data as an associative array, a numeric array, or both (the default).
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ stmt
+
+
+ A statement resource returned by sqlsrv_query or sqlsrv_execute.
+
+
+
+
+ fetchType
+
+
+ A predefined constant specifying the type of array to return. Possible values are SQLSRV_FETCH_ASSOC, SQLSRV_FETCH_NUMERIC, and SQLSRV_FETCH_BOTH (the default).
+
+
+
+
+ row
+
+
+ Specifies the row to access in a result set that uses a scrollable cursor. Possible values are SQLSRV_SCROLL_NEXT, SQLSRV_SCROLL_PRIOR, SQLSRV_SCROLL_FIRST, SQLSRV_SCROLL_LAST, SQLSRV_SCROLL_ABSOLUTE and, SQLSRV_SCROLL_RELATIVE (the default).
+
+
+ When this parameter is specified, the fetchType must be explicitly defined.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ If a row is successfully retrieved, an array is returned. If there are no more rows to retrieve, null is returned. If an error occurs, false is returned.
+
+
+ If more than one column is returned with the same name, the last column will take precedence. To avoid field name collisions, use aliases.
+
+
+ If a column with no name is returned, the associative key for the array element will be an empty string ("").
+
+
+
+
+ &reftitle.examples;
+
+
+ Retrieving an associative array.
+
+"dbName", "UID"=>"username", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo );
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$sql = "SELECT FirstName, LastName FROM SomeTable";
+$stmt = sqlsrv_query( $conn, $sql );
+if( $stmt === false) {
+ die( print_r( sqlsrv_errors(), true) );
+}
+
+while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
+ echo $row['LastName'].", ".$row['FirstName']." ";
+}
+
+sqlsrv_free_stmt( $stmt);
+?>
+]]>
+
+
+
+
+
+ Retrieving a numeric array.
+
+"dbName", "UID"=>"username", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo );
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$sql = "SELECT FirstName, LastName FROM SomeTable";
+$stmt = sqlsrv_query( $conn, $sql );
+if( $stmt === false) {
+ die( print_r( sqlsrv_errors(), true) );
+}
+
+while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC) ) {
+ echo $row[0].", ".$row[1]." ";
+}
+
+sqlsrv_free_stmt( $stmt);
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.notes;
+
+ Not specifying the fetchType or explicity using the SQLSRV_FETCH_TYPE constant in the examples above will return an array that has both associative and numeric keys.
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_connect
+ sqlsrv_query
+ sqlsrv_errors
+ sqlsrv_fetch
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-fetch-object.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-fetch-object.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-fetch-object.xml (revision 0)
@@ -0,0 +1,171 @@
+
+
+
+
+ sqlsrv_fetch_object
+ Retrieve the next row of data in a result set as an object.
+
+
+ &reftitle.description;
+
+ mixedsqlsrv_fetch_object
+ resourcestmt
+ stringclassName
+ arrayctorParams
+ introw
+ intoffset
+
+
+ Retrieves the next row of data in a result set as an object.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ stmt
+
+
+ A statement resource created by sqlsrv_query or sqlsrv_execute.
+
+
+
+
+ className
+
+
+ The name of the class to instantiate. If no class name is specified, stdClass is instantiated.
+
+
+
+
+ ctorParams
+
+
+ Values passed to the constructor of the specified class. If the constructor of the specified class takes parameters, the ctorParams array must be supplied.
+
+
+
+
+ row
+
+
+ The row to be accessed. This parameter can only be used if the specified statement was prepared with a scrollable cursor. In that case, this parameter can take on one of the following values:
+
+ SQLSRV_SCROLL_NEXT
+ SQLSRV_SCROLL_PRIOR
+ SQLSRV_SCROLL_FIRST
+ SQLSRV_SCROLL_LAST
+ SQLSRV_SCROLL_ABSOLUTE
+ SQLSRV_SCROLL_RELATIVE
+
+
+
+
+
+ offset
+
+
+ Specifies the row to be accessed if the row parameter is set to SQLSRV_SCROLL_ABSOLUTE or SQLSRV_SCROLL_RELATIVE. Note that the first row in a result set has index 0.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ On success, an instance of the specified class with properties that match the row field names and values that correspond to the row field values.
+ If the specified statement has no active result sets or if the specified class does not exist, FALSE is returned.
+ If there are no more rows in the result set, NULL is returned.
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_fetch_object example
+
+ The following example demonstrates how to retrieve a row as a stdClass object.
+
+
+"dbName", "UID"=>"username", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$tsql = "SELECT fName, lName FROM Table_1";
+$stmt = sqlsrv_query( $conn, $tsql);
+if( $stmt === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+// Retrieve each row as a PHP object.
+// Because no class is specified, each row will be retrieved as a stdClass object.
+// Property names correspond to field names.
+while( $obj = sqlsrv_fetch_object( $stmt)) {
+ echo $obj->fName.", ".$obj->lName." ";
+}
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.notes;
+
+ If a class name is specified with the optional $className parameter and the class has properties whose names match the result set field names, the corresponding result set values are applied to the properties.
+ If a result set field name does not match a class property, a property with the result set field name is added to the object and the result set value is applied to the property.
+ The following rules apply when using the $className parameter:
+
+ Field-property name matching is case-sensitive.
+ Field-property matching occurs regardless of access modifiers.
+ Class property data types are ignored when applying a field value to a property.
+ If the class does not exist, the function returns FALSE and adds an error to the error collection.
+
+ Regardless of whether the $className parameter is supplied, if a field with no name is returned, the field value will be ignored and a warning will be added to the error collection.
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_fetch
+ sqlsrv_fetch_array
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-fetch.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-fetch.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-fetch.xml (revision 0)
@@ -0,0 +1,146 @@
+
+
+
+
+ sqlsrv_fetch
+ Make the next row in a result set available for reading. Use sqlsrv_get_field to read the fields of the row.
+
+
+ &reftitle.description;
+
+
+ mixedsqlsrv_fetch
+ resourcestmt
+ introw
+ intoffset
+
+
+ Makes the next row in a result set available for reading. Use sqlsrv_get_field to read the fields of the row.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ stmt
+
+
+ A statement resource created by executing sqlsrv_query or sqlsrv_execute.
+
+
+
+
+ row
+
+
+ The row to be accessed. This parameter can only be used if the specified statement was prepared with a scrollable cursor. In that case, this parameter can take on one of the following values:
+
+ SQLSRV_SCROLL_NEXT
+ SQLSRV_SCROLL_PRIOR
+ SQLSRV_SCROLL_FIRST
+ SQLSRV_SCROLL_LAST
+ SQLSRV_SCROLL_ABSOLUTE
+ SQLSRV_SCROLL_RELATIVE
+
+
+
+
+
+ offset
+
+
+ Specifies the row to be accessed if the row parameter is set to SQLSRV_SCROLL_ABSOLUTE or SQLSRV_SCROLL_RELATIVE. Note that the first row in a result set has index 0.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ TRUE if the next row of a result set was successfully retrieved. If an error occurred, FALSE is returned. If no more rows in the result set, NULL is returned.
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_fetch example
+
+ The following example demonstrates how to retrieve a row with sqlsrv_fetch and get the row fields with sqlsrv_get_field.
+
+
+"dbName", "UID"=>"username", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$sql = "SELECT Name, Comment
+ FROM Table_1
+ WHERE ReviewID=1";
+$stmt = sqlsrv_query( $conn, $sql);
+if( $stmt === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+// Make the first (and in this case, only) row of the result set available for reading.
+if( sqlsrv_fetch( $stmt ) === false) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+// Get the row fields. Field indeces start at 0 and must be retrieved in order.
+// Retrieving row fields by name is not supported by sqlsrv_get_field.
+$name = sqlsrv_get_field( $stmt, 0);
+echo "$name: ";
+
+$comment = sqlsrv_get_field( $stmt, 1);
+echo $comment;
+?>
+]]>
+
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_get_field
+ sqlsrv_fetch_array
+ sqlsrv_fetch_object
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-field-metadata.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-field-metadata.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-field-metadata.xml (revision 0)
@@ -0,0 +1,141 @@
+
+
+
+
+ sqlsrv_field_metadata
+ Retrieve metadata for the fields of a statement prepared by sqlsrv_prepare or sqlsrv_query.
+
+
+ &reftitle.description;
+
+ mixedsqlsrv_field_metadata
+ resourcestmt
+
+
+ Retrieves metadata for the fields of a statement prepared by sqlsrv_prepare or sqlsrv_query.
+ sqlsrv_field_metadata can be called on a statement before or after statement execution.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ stmt
+
+
+ The statment resource for which metadata is returned.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ On success, an array of arrays is returned. Otherwise, FALSE is returned. Each returned array is described by the following table:
+
+ Array returned by sqlsrv_field_metadata
+
+
+
+ Key
+ Description
+
+
+
+
+ Name
+ The name of the field.
+
+
+ Type
+ The numeric value for the SQL type.
+
+
+ Size
+ The number of characters for fields of character type, the number of bytes for fields of binary type, or NULL for other types.
+
+
+ Precision
+ The precision for types of variable precision, NULL for other types.
+
+
+ Scale
+ The scale for types of variable scale, NULL for other types.
+
+
+ Nullable
+ An enumeration indicating whether the column is nullable, not nullable, or if it is not known.
+
+
+
+
+ For more information, see sqlsrv_field_metadata in the Microsoft SQLSRV documentation.
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_field_metadata example
+
+"AdventureWorks", "UID"=>"username", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$sql = "SELECT * FROM Table_1";
+$stmt = sqlsrv_prepare( $conn, $sql );
+
+foreach( sqlsrv_field_metadata( $stmt ) as $fieldMetadata ) {
+ foreach( $fieldMetadata as $name => $value) {
+ echo "$name: $value ";
+ }
+ echo " ";
+}
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_client_info
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-free-stmt.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-free-stmt.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-free-stmt.xml (revision 0)
@@ -0,0 +1,113 @@
+
+
+
+
+ sqlsrv_free_stmt
+ Free all resources for the specified statement.
+
+
+ &reftitle.description;
+
+ boolsqlsrv_free_stmt
+ resourcestmt
+
+
+ Frees all resources for the specified statement. The statement cannot be used after sqlsrv_free_stmt has been called on it.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ stmt
+
+
+ The statment for which resources are freed.
+ Note that NULL is a valid parameter value. This allows the function to be called multiple times in a script.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ &return.success;
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_free_stmt example
+
+"dbName", "UID"=>"username", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$stmt = sqlsrv_query( $conn, "SELECT * FROM Table_1");
+if( $stmt === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+/*-------------------------------
+ Process query results here.
+-------------------------------*/
+
+/* Free the statement resources. */
+sqlsrv_free_stmt( $stmt);
+
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.notes;
+
+ The main difference between sqlsrv_free_stmt and sqlsrv_cancel is that a statement resource cancelled with sqlsrv_cancel can be re-executed if it was created with sqlsrv_prepare.
+ A statement resource cancelled with sqlsrv_free_statement cannot be re-executed.
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_cancel
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-get-config.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-get-config.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-get-config.xml (revision 0)
@@ -0,0 +1,71 @@
+
+
+
+
+ sqlsrv_get_config
+ Return the value of the specified configuration setting.
+
+
+ &reftitle.description;
+
+ mixedsqlsrv_get_config
+ stringsetting
+
+
+ Returns the value of the specified configuration setting.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ setting
+
+
+ The name of the setting for which the value is returned. For a list of configurable settings, see sqlsrv_configure.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ The value of the specified setting. If an invalid setting is specified, FALSE is returned.
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_configure
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-get-field.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-get-field.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-get-field.xml (revision 0)
@@ -0,0 +1,137 @@
+
+
+
+
+ sqlsrv_get_field
+ Get field data from the currently selected row. Fields must be accessed in order.
+
+
+ &reftitle.description;
+
+ mixedsqlsrv_get_field
+ resourcestmt
+ intfieldIndex
+ intgetAsType
+
+
+ Gets field data from the currently selected row. Fields must be accessed in order. Field indices start at 0.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ stmt
+
+
+ A statement resource returned by sqlsrv_query or sqlsrv_execute.
+
+
+
+
+ fieldIndex
+
+
+ The index of the field to be retrieved. Field indices start at 0. Fields must be accessed in order. i.e. If you access field index 1, then field index 0 will not be available.
+
+
+
+
+ getAsType
+
+
+ The PHP data type for the returned field data. If this parameter is not set, the field data will be returned as its default PHP data type.
+ For information about default PHP data types, see Default PHP Data Types in the Microsoft SQLSRV documentation.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ On success, the field data is returned. On failure, FALSE is returned.
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_get_field example
+
+ The following example demonstrates how to retrieve a row with sqlsrv_fetch and get the row fields with sqlsrv_get_field.
+
+
+"dbName", "UID"=>"username", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$sql = "SELECT Name, Comment
+ FROM Table_1
+ WHERE ReviewID=1";
+$stmt = sqlsrv_query( $conn, $sql);
+if( $stmt === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+// Make the first (and in this case, only) row of the result set available for reading.
+if( sqlsrv_fetch( $stmt ) === false) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+// Get the row fields. Field indeces start at 0 and must be retrieved in order.
+// Retrieving row fields by name is not supported by sqlsrv_get_field.
+$name = sqlsrv_get_field( $stmt, 0);
+echo "$name: ";
+
+$comment = sqlsrv_get_field( $stmt, 1);
+echo $comment;
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_fetch
+ sqlsrv_fetch_array
+ sqlsrv_fetch_object
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-has-rows.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-has-rows.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-has-rows.xml (revision 0)
@@ -0,0 +1,100 @@
+
+
+
+
+ sqlsrv_has_rows
+ Indicate whether the specified statement has rows.
+
+
+ &reftitle.description;
+
+ boolsqlsrv_has_rows
+ resourcestmt
+
+
+ Indicates whether the specified statement has rows.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ stmt
+
+
+ A statement resource returned by sqlsrv_query or sqlsrv_execute.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ TRUE if the specified statement has rows. FALSE if the statement does not have rows or if an error occured.
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_has_rows example
+
+"dbName", "UID"=>"username", "PWD"=>"password" )
+$conn = sqlsrv_connect( $server, $connectionInfo );
+
+$stmt = sqlsrv_query( $conn, "SELECT * FROM Table_1");
+
+if ($stmt) {
+ $rows = sqlsrv_has_rows( $stmt );
+ if ($rows === true)
+ echo "There are rows. ";
+ else
+ echo "There are no rows. ";
+}
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_num_rows
+ sqlsrv_query
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-next-result.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-next-result.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-next-result.xml (revision 0)
@@ -0,0 +1,116 @@
+
+
+
+
+ sqlsrv_next_result
+ Make the next result of the specified statement active. Results include result sets, row counts, and output parameters.
+
+
+ &reftitle.description;
+
+ mixedsqlsrv_next_result
+
+ resourcestmt
+
+
+ Makes the next result of the specified statement active. Results include result sets, row counts, and output parameters.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ stmt
+
+
+ The statment on which the next result is being called.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ TRUE if the next result was successfully retrieved. FALSE if an error occurred. If there are no more results to retrieve, NULL is returned.
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_next_result example
+
+ The following example executes a batch query that inserts into a table and then selects from the table.
+ This produces two results on the statement: one for the rows affected by the INSERT and one for the rows returned by the SELECT.
+ To get to the rows returned by the SELECT, sqlsrv_next_result must be called to move past the first result.
+
+
+"dbName", "UID"=>"userName", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+
+$query = "INSERT INTO Table_1 (id, data) VALUES (?,?); SELECT * FROM TABLE_1;";
+$params = array(1, "some data");
+$stmt = sqlsrv_query($conn, $query, $params);
+
+// Consume the first result (rows affected by INSERT) without calling sqlsrv_next_result.
+echo "Rows affected: ".sqlsrv_rows_affected($stmt)." ";
+
+// Move to the next result and display results.
+$next_result = sqlsrv_next_result($stmt);
+if( $next_result ) {
+ while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC)){
+ echo $row['id'].": ".$row['data']." ";
+ }
+} elseif( is_null($next_result)) {
+ echo "No more results. ";
+} else {
+ die(print_r(sqlsrv_errors(), true));
+}
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_query
+ sqlsrv_fetch_array
+ sqlsrv_rows_affected
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-num-fields.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-num-fields.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-num-fields.xml (revision 0)
@@ -0,0 +1,111 @@
+
+
+
+
+ sqlsrv_num_fields
+ Retrieve the number of fields (columns) on a statement.
+
+
+ &reftitle.description;
+
+ mixedsqlsrv_num_fields
+ resourcestmt
+
+
+ Retrieves the number of fields (columns) on a statement.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ stmt
+
+
+ The statment for which the number of fields is returned. sqlsrv_num_fields can be called on any statement pre or post execution.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ On success, the number of fields. On failure, FALSE is returned.
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_num_fields example
+
+"dbName", "UID"=>"username", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$sql = "SELECT * FROM Table_1";
+$stmt = sqlsrv_query($conn, $sql);
+if( $stmt === false) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$numFields = sqlsrv_num_fields( $stmt );
+
+while( sqlsrv_fetch( $stmt )) {
+ // Iterate through the fields of each row.
+ for($i = 0; $i < $numFields; $i++) {
+ {
+ echo sqlsrv_get_field($stmt, $i)." ";
+ }
+ echo " ";
+}
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_field_metadata
+ sqlsrv_fetch
+ sqlsrv_get_field
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-num-rows.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-num-rows.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-num-rows.xml (revision 0)
@@ -0,0 +1,105 @@
+
+
+
+
+ sqlsrv_num_rows
+ Retrieve the number of rows in a result set.
+
+
+ &reftitle.description;
+
+ mixedsqlsrv_num_rows
+ resourcestmt
+
+
+ Retrieves the number of rows in a result set. This function requires that the statment resource be created with a static or keyset cursor.
+ For more information, see sqlsrv_query, sqlsrv_prepare, or Specifying a Cursor Type and Selecting Rows in the Microsoft SQLSRV documentation.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ stmt
+
+
+ The statement for which the row count is returned.
+ The statment resource be created with a static or keyset cursor.
+ For more information, see sqlsrv_query, sqlsrv_prepare, or Specifying a Cursor Type and Selecting Rows in the Microsoft SQLSRV documentation.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ On success, the number of rows is returned. If an error occurred, FALSE is returned. If a forward cursor (the default) or dynamic cursor is used, FALSE is returned.
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_num_rows example
+
+"dbName", "UID"=>"username", "PWD"=>"password" );
+$conn = sqlsrv_connect( $server, $connectionInfo );
+
+$sql = "SELECT * FROM Table_1";
+$params = array();
+$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
+$stmt = sqlsrv_query( $conn, $sql , $params, $options );
+
+$row_count = sqlsrv_num_rows( $stmt );
+
+if ($row_count === false)
+ echo "Error in retrieveing row count.";
+else
+ echo $row_count;
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_has_rows
+ sqlsrv_rows_affected
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-prepare.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-prepare.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-prepare.xml (revision 0)
@@ -0,0 +1,221 @@
+
+
+
+
+ sqlsrv_prepare
+ Prepare a query for execution.
+
+
+ &reftitle.description;
+
+ mixedsqlsrv_prepare
+ resourceconn
+ stringsql
+ arrayparams
+ arrayoptions
+
+
+ Prepares a query for execution. This function is ideal for preparing a query that will be executed multiple times with different parameter values.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ conn
+
+
+ A connection resource returned by sqlsrv_connect.
+
+
+
+
+ sql
+
+
+ The string that defines the query to be prepared and executed.
+
+
+
+
+ params
+
+
+ An array specifying parameter information when executing a parameterized query. Array elements can be any of the following:
+
+ A literal value
+ A PHP variable
+ An array with this structure: array($value [, $direction [, $phpType [, $sqlType]]])
+
+ The following table describes the elements in the array structure above:
+
+
+ Array structure
+
+
+
+ Element
+ Description
+
+
+
+
+ $value
+ A literal value, a PHP variable, or a PHP by-reference variable.
+
+
+ $direction (optional)
+ One of the following SQLSRV constants used to indicate the parameter direction: SQLSRV_PARAM_IN, SQLSRV_PARAM_OUT, SQLSRV_PARAM_INOUT. The default value is SQLSRV_PARAM_IN.
+
+
+ $phpType (optional)
+ A SQLSRV_PHPTYPE_* constant that specifies PHP data type of the returned value.
+
+
+ $sqlType (optional)
+ A SQLSRV_SQLTYPE_* constant that specifies the SQL Server data type of the input value.
+
+
+
+
+
+
+
+ options
+
+
+ An array specifing query property options. The supported keys are described in the following table:
+
+
+ Query Options
+
+
+
+ Key
+ Values
+ Description
+
+
+
+
+ QueryTimeout
+ A positive integer value.
+ Sets the query timeout in seconds. By default, the driver will wait indefinitely for results.
+
+
+ SendStreamParamsAtExec
+ TRUE or FALSE (the default is TRUE)
+ Configures the driver to send all stream data at execution (TRUE), or to send stream data in chunks (FALSE). By default, the value is set to TRUE. For more information, see sqlsrv_send_stream_data.
+
+
+ Scrollable
+ SQLSRV_CURSOR_FORWARD, SQLSRV_CURSOR_STATIC, SQLSRV_CURSOR_DYNAMIC, orSQLSRV_CURSOR_KEYSET
+ See Specifying a Cursor Type and Selecting Rows in the Microsoft SQLSRV documentation.
+
+
+
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ On success, a statement resource is returned. If the query cannot be prepared, FALSE is returned.
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_prepare example
+
+ This example demonstrates how to prepare a statement with sqlsrv_prepare and re-execute it multiple times (with different parameter values) using sqlsrv_execute.
+
+
+"dbName", "UID"=>"username", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+if( $conn === false) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$sql = "UPDATE Table_1
+ SET OrderQty = ?
+ WHERE SalesOrderID = ?";
+
+// Initialize parameters and prepare the statement.
+// Variables $qty and $id are bound to the statement, $stmt.
+$qty = 0; $id = 0;
+$stmt = sqlsrv_prepare( $conn, $sql, array( &$qty, &$id));
+if( !$stmt ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+// Set up the SalesOrderDetailID and OrderQty information.
+// This array maps the order ID to order quantity in key=>value pairs.
+$orders = array( 1=>10, 2=>20, 3=>30);
+
+// Execute the statement for each order.
+foreach( $orders as $id => $qty) {
+ // Because $id and $qty are bound to $stmt1, their updated
+ // values are used with each execution of the statement.
+ if( sqlsrv_execute( $stmt ) === false ) {
+ die( print_r( sqlsrv_errors(), true));
+ }
+}
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.notes;
+
+ When you prepare a statement that uses variables as parameters, the variables are bound to the statement.
+ This means that if you update the values of the variables, the next time you execute the statement it will run with updated parameter values.
+ For statements that you plan to execute only once, use sqlsrv_query.
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_execute
+ sqlsrv_query
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-query.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-query.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-query.xml (revision 0)
@@ -0,0 +1,199 @@
+
+
+
+
+ sqlsrv_query
+ Prepare and execute a query.
+
+
+ &reftitle.description;
+
+ mixedsqlsrv_query
+ resourceconn
+ stringsql
+ arrayparams
+ arrayoptions
+
+
+ Prepares and executes a query
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ conn
+
+
+ A connection resource returned by sqlsrv_connect.
+
+
+
+
+ sql
+
+
+ The string that defines the query to be prepared and executed.
+
+
+
+
+ params
+
+
+ An array specifying parameter information when executing a parameterized query. Array elements can be any of the following:
+
+ A literal value
+ A PHP variable
+ An array with this structure: array($value [, $direction [, $phpType [, $sqlType]]])
+
+ The following table describes the elements in the array structure above:
+
+
+ Array structure
+
+
+
+ Element
+ Description
+
+
+
+
+ $value
+ A literal value, a PHP variable, or a PHP by-reference variable.
+
+
+ $direction (optional)
+ One of the following SQLSRV constants used to indicate the parameter direction: SQLSRV_PARAM_IN, SQLSRV_PARAM_OUT, SQLSRV_PARAM_INOUT. The default value is SQLSRV_PARAM_IN.
+
+
+ $phpType (optional)
+ A SQLSRV_PHPTYPE_* constant that specifies PHP data type of the returned value.
+
+
+ $sqlType (optional)
+ A SQLSRV_SQLTYPE_* constant that specifies the SQL Server data type of the input value.
+
+
+
+
+
+
+
+ options
+
+
+ An array specifing query property options. The supported keys are described in the following table:
+
+
+ Query Options
+
+
+
+ Key
+ Values
+ Description
+
+
+
+
+ QueryTimeout
+ A positive integer value.
+ Sets the query timeout in seconds. By default, the driver will wait indefinitely for results.
+
+
+ SendStreamParamsAtExec
+ TRUE or FALSE (the default is TRUE)
+ Configures the driver to send all stream data at execution (TRUE), or to send stream data in chunks (FALSE). By default, the value is set to TRUE. For more information, see sqlsrv_send_stream_data.
+
+
+ Scrollable
+ SQLSRV_CURSOR_FORWARD, SQLSRV_CURSOR_STATIC, SQLSRV_CURSOR_DYNAMIC, orSQLSRV_CURSOR_KEYSET
+ See Specifying a Cursor Type and Selecting Rows in the Microsoft SQLSRV documentation.
+
+
+
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ On success, a statement resource is returned. If the query cannot be prepared and/or executed, FALSE is returned.
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_query example
+
+"dbName", "UID"=>"username", "PWD"=>"password" );
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$sql = "INSERT INTO Table_1 (id, data) VALUES (?, ?)";
+$params = array(1, "some data");
+
+$stmt = sqlsrv_query( $conn, $tsql, $params);
+if( $stmt === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.notes;
+
+ For statements that you plan to execute only once, use the sqlsrv_query. If you intend to re-execute a statement with different parameter values, use the combination of sqlsrv_prepare and sqlsrv_execute.
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_prepare
+ sqlsrv_execute
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-rollback.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-rollback.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-rollback.xml (revision 0)
@@ -0,0 +1,127 @@
+
+
+
+
+ sqlsrv_rollback
+ Roll back a transaction that was begun with sqlsrv_begin_transaction.
+
+
+ &reftitle.description;
+
+ boolsqlsrv_rollback
+ resourceconn
+
+
+ Rolls back a transaction that was begun with sqlsrv_begin_transaction and returns the connection to auto-commit mode.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ conn
+
+
+ The connection resource returned by a call to sqlsrv_connect.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ &return.success;
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_rollback example
+
+ The following example demonstrates how to use sqlsrv_begin_transaction together with sqlsrv_commit and sqlsrv_rollback.
+
+
+"dbName", "UID"=>"userName", "PWD"=>"password");
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true ));
+}
+
+/* Begin the transaction. */
+if ( sqlsrv_begin_transaction( $conn ) === false ) {
+ die( print_r( sqlsrv_errors(), true ));
+}
+
+/* Initialize parameter values. */
+$orderId = 1; $qty = 10; $productId = 100;
+
+/* Set up and execute the first query. */
+$sql1 = "INSERT INTO OrdersTable (ID, Quantity, ProductID)
+ VALUES (?, ?, ?)";
+$params1 = array( $orderId, $qty, $productId );
+$stmt1 = sqlsrv_query( $conn, $sql1, $params1 );
+
+/* Set up and execute the second query. */
+$sql2 = "UPDATE InventoryTable
+ SET Quantity = (Quantity - ?)
+ WHERE ProductID = ?";
+$params2 = array($qty, $productId);
+$stmt2 = sqlsrv_query( $conn, $sql2, $params2 );
+
+/* If both queries were successful, commit the transaction. */
+/* Otherwise, rollback the transaction. */
+if( $stmt1 && $stmt2 ) {
+ sqlsrv_commit( $conn );
+ echo "Transaction committed. ";
+} else {
+ sqlsrv_rollback( $conn );
+ echo "Transaction rolled back. ";
+}
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_begin_transaction
+ sqlsrv_commit
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-rows-affected.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-rows-affected.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-rows-affected.xml (revision 0)
@@ -0,0 +1,107 @@
+
+
+
+
+ sqlsrv_rows_affected
+ Return the number of rows modified (INSERT, UPDATE, DELETE) by the last executed query. For information about the number of rows returned by a SELECT query, see sqlsrv_num_rows.
+
+
+ &reftitle.description;
+
+ mixedsqlsrv_rows_affected
+ resourcestmt
+
+
+ Returns the number of rows modified (INSERT, UPDATE, DELETE) by the last executed query. For information about the number of rows returned by a SELECT query, see sqlsrv_num_rows.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ stmt
+
+
+ The executed statement resource for which the number of affected rows is returned.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ The number of rows affected by the last INSERT, UPDATE, or DELETE query. If no rows were affected, 0 is returned. If the number of affected rows cannot be determined, -1 is returned. If an error occured, FALSE is returned.
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_rows_affected example
+
+"dbName", "UID"=>"username", "PWD"=>"password" );
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$tsql = "UPDATE Table_1 SET data = ? WHERE id = ?";
+
+$params = array("updated data", 1);
+
+$stmt = sqlsrv_query( $conn, $tsql, $params);
+
+$rows_affected = sqlsrv_rows_affected( $stmt);
+if( $rows_affected === false) {
+ die( print_r( sqlsrv_errors(), true));
+} elseif( $rows_affected == -1) {
+ echo "No information available. ";
+} else {
+ echo $rows_affected." rows were updated. ";
+}
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_num_rows
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-send-stream-data.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-send-stream-data.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-send-stream-data.xml (revision 0)
@@ -0,0 +1,115 @@
+
+
+
+
+ sqlsrv_send_stream_data
+ Send data from parameter streams to the server. Up to 8 KB of data is sent with each call.
+
+
+ &reftitle.description;
+
+ boolsqlsrv_send_stream_data
+ resourcestmt
+
+
+ Send data from parameter streams to the server. Up to 8 KB of data is sent with each call.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ stmt
+
+
+ A statement resource returned by sqlsrv_query or sqlsrv_execute.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ TRUE if there is more data to send, FALSE if there is not.
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_send_stream_data example
+
+"dbName", "UID"=>"username", "PWD"=>"password" );
+$conn = sqlsrv_connect( $serverName, $connectionInfo);
+if( $conn === false ) {
+ die( print_r( sqlsrv_errors(), true));
+}
+
+$sql = "UPDATE Table_1 SET data = ( ?) WHERE id = 100";
+
+// Open parameter data as a stream and put it in the $params array.
+$data = fopen( "data://text/plain,[ Lengthy content here. ]", "r");
+$params = array( &$data);
+
+// Prepare the statement. Use the $options array to turn off the
+// default behavior, which is to send all stream data at the time of query
+// execution.
+$options = array("SendStreamParamsAtExec"=>0);
+$stmt = sqlsrv_prepare( $conn, $sql, $params, $options);
+
+sqlsrv_execute( $stmt);
+
+// Send up to 8K of parameter data to the server
+// with each call to sqlsrv_send_stream_data.
+$i = 1;
+while( sqlsrv_send_stream_data( $stmt)) {
+ $i++;
+}
+echo "$i calls were made.";
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_prepare
+ sqlsrv_query
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/functions/sqlsrv-server-info.xml
===================================================================
--- en/reference/sqlsrv/functions/sqlsrv-server-info.xml (revision 0)
+++ en/reference/sqlsrv/functions/sqlsrv-server-info.xml (revision 0)
@@ -0,0 +1,122 @@
+
+
+
+
+ sqlsrv_server_info
+ Return information about the server.
+
+
+ &reftitle.description;
+
+ arraysqlsrv_server_info
+ resourceconn
+
+
+ Returns information about the server.
+
+
+
+
+ &reftitle.parameters;
+
+
+
+ conn
+
+
+ The connection resource that connects the client and the server.
+
+
+
+
+
+
+
+
+ &reftitle.returnvalues;
+
+ An array as described in the following table:
+
+ Returned Array
+
+
+
+ CurrentDatabase
+ The connected-to database.
+
+
+
+
+ SQLServerVersion
+ The SQL Server version.
+
+
+ SQLServerName
+ The name of the server.
+
+
+
+
+
+
+
+
+ &reftitle.examples;
+
+
+ sqlsrv_server_info example
+
+ $value) {
+ echo $key.": ".$value." ";
+ }
+} else {
+ die( print_r( sqlsrv_errors(), true));
+}
+?>
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ sqlsrv_client_info
+
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/ini.xml
===================================================================
--- en/reference/sqlsrv/ini.xml (revision 0)
+++ en/reference/sqlsrv/ini.xml (revision 0)
@@ -0,0 +1,83 @@
+
+
+
+ &reftitle.runtime;
+ &extension.runtime;
+ The following table lists the configuration options available in the SQLSRV extension. For more information about these options, see Handling SQLSRV Warnings and Errors.
+
+
+ SQLSRV &ConfigureOptions;
+
+
+
+ &Name;
+ &Default;
+ &Changeable;
+ Changelog
+
+
+
+
+ sqlsrv.WarningsReturnAsErrors
+ 1 (true)
+ PHP_INI_ALL
+ Available since SQLSRV 1.0
+
+
+ sqlsrv.LogSubsystems
+ 0
+ PHP_INI_ALL
+ Available since SQLSRV 1.0
+
+
+ sqlsrv.LogSeverity
+ 1
+ PHP_INI_ALL
+ Available since SQLSRV 1.0
+
+
+
+
+
+
+
+
+ &ini.descriptions.title;
+
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/reference.xml
===================================================================
--- en/reference/sqlsrv/reference.xml (revision 0)
+++ en/reference/sqlsrv/reference.xml (revision 0)
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+ SQLSRV &Functions;
+ SQLSRV
+
+
+
+ &reftitle.intro;
+
+ Test
+
+
+
+
+ &reftitle.required;
+
+
+
+
+
+ &reference.sqlsrv.configure;
+ &reference.sqlsrv.ini;
+
+
+ &reftitle.resources;
+ &no.resource;
+
+
+ &reference.sqlsrv.constants;
+
+
+
+&reference.sqlsrv.entities.functions;
+
+
+
+
\ No newline at end of file
Index: en/reference/sqlsrv/setup.xml
===================================================================
--- en/reference/sqlsrv/setup.xml (revision 0)
+++ en/reference/sqlsrv/setup.xml (revision 0)
@@ -0,0 +1,88 @@
+
+
+
+
+ &reftitle.setup;
+
+
+
+ &reftitle.required;
+
+ The SQLSRV extension can be used on the following operating systems:
+
+ Windows Server 2003 Service Pack 1
+ Windows XP Service Pack 3
+ Windows Vista Service Pack 1 or later
+ Windows Server 2008
+ Windows Server 2008 R2
+ Windows 7
+
+
+
+ The SQLSRV requires that the Microsoft SQL Server 2008 R2 Native Client be installed on the same computer that is running PHP. If the Microsoft SQL Server 2008 R2 is not already installed, click the appropriate link below to download it:
+
+ Download the x86 package
+ Download the x64 package
+
+
+
+ Which driver file you use will depend on which PHP version you are using, whether you are using thread-safe or non-thread-safe PHP, and whether your PHP installation was compiled with the VC6 or VC9 compiler.
+ If you are running PHP 5.3, you are using non-thread-safe PHP, and your PHP installation was compiled with the VC9 compiler, you should use the php_sqlsrv_53_nts_vc9.dll file.
+ (You should use a non-thread-safe version compiled with the VC9 compiler if you are using IIS as your web server). If you are running PHP 5.2, you are using thread-safe PHP, and your PHP installation was compiled
+ with the VC6 compiler, you should use the php_sqlsrv_52_ts_vc6.dll file.
+
+
+ For more information about SQLSRV requirements, see SQLSRV System Requirements.
+
+
+
+
+
+ &reference.sqlsrv.configure;
+
+
+
+ &reference.sqlsrv.ini;
+
+
+
+
+ &reftitle.resources;
+
+ Connection resource
+
+ A connection resource returned by sqlsrv_connect.
+
+
+
+ Statement resource
+
+ A statement resource returned by sqlsrv_query or by sqlsrv_prepare.
+
+
+
+
+
+
+
+
+