SQL Server Driver PHP commands compared with MySQL PHP commands

Over the years I have used the inbuilt PHP drivers for MySQL. The best mechanism for mapping the two methods is a simple table laying out a comparison between the two systems.

Note this is not a SQLServer vs. MySQL argument, just for information and reference.

As the SQLServer drivers change, I will update this page.

Note:

sqlsrv_client_info(  ) DriverDllName: SQLNCLI.DLL DriverODBCVer: 03.52 DriverVer: 09.00.3042 ExtensionVer: 1.0.1015.0

 

 

Description SQLServer Driver for PHP MySQL Functions
Begins a transaction sqlsrv_begin_transaction( resource $conn ) START TRANSACTION, BEGIN, COMMIT, ROLLBACK can be executed as statements in mysql_query
Cancels a statement; discards any pending results for the statement sqlsrv_cancel( resource $stmt ) -
Provides information about the client sqlsrv_client_info( resource $conn ) mysql_get_client_info ( void )
Closes a connection. Frees all resources associated with the connection sqlsrv_close( resource $conn ) mysql_close ([ resource $link_identifier ] )
Commits a transaction sqlsrv_commit( resource $conn ) START TRANSACTION, BEGIN, COMMIT, ROLLBACK can be executed as statements in mysql_query
Changes error handling and logging configurations sqlsrv_configure( string $setting, int $value ) -
Creates and opens a connection sqlsrv_connect( string $serverName [, array $connectionInfo ) mysql_connect ([ string $server [, string $username [, string $password [, bool $new_link [, int $client_flags ]]]]] )
Returns error and/or warning information about the last operation sqlsrv_errors( [int $errosAndOrWarnings] ) mysql_errno ([ resource $link_identifier ] ) mysql_error ([ resource $link_identifier ] )
Executes a prepared statement with sqlsrv_prepare sqlsrv_execute( resource $stmt ) -
Makes the next row of data available for reading sqlsrv_fetch( resource $stmt ) -
Retrieves the next row of data as a numerically indexed array, an associative array, or both sqlsrv_fetch_array( resource $stmt [, int $fetchType] ) mysql_fetch_array ( resource $result [, int $result_type ] )
Retrieves the next row of data as an object sqlsrv_fetch_object( resource $stmt [, string $className] ) mysql_fetch_object ( resource $result [, string $class_name [, array $params ]] )
Returns field metadata sqlsrv_field_metadata( resource $stmt ) See mysql_field_type ( resource $result , int $field_offset ) specifically the Example and mysql_fetch_field ( resource $result [, int $field_offset ] )
Closes a statement. Frees all resources associated with the statement sqlsrv_free_stmt( resource $stmt ) mysql_free_result ( resource $result )
Returns the value of the specified configuration setting sqlsrv_get_config( string $setting ) mysql_get_client_info ( void )

Retrieves a field in the current row by index. The PHP return type can be specified

sqlsrv_get_field( resource $stmt, int $fieldIndex [, int $getAsType] ) similar to mysql_result ( resource $result , int $row [, mixed $field ] )
Makes the next result available for processing sqlsrv_next_result( resource $stmt ) -
Retrieves the number of fields in an active result set sqlsrv_num_fields( resource $stmt ) mysql_num_fields ( resource $result )
Prepares a Transact-SQL query without executing it. Implicitly binds parameters, executed with sqlsrv_execute sqlsrv_prepare( resource $conn, string $tsql[ ,array $params[, array $options]] ) -
Prepares and executes a Transact-SQL query. sqlsrv_query( resource $conn, string $tsql[ , array $params[, array $options]] ) mysql_query ( string $query [, resource $link_identifier ] )
Rolls back a transaction. sqlsrv_rollback( resource $conn ) START TRANSACTION, BEGIN, COMMIT, ROLLBACK can be executed as statements in mysql_query
Returns the number of modified rows. sqlsrv_rows_affected( resource $stmt ) mysql_affected_rows ([ resource $link_identifier ] )
Sends up to eight kilobytes (8 KB) of data to the server with each call to the function. sqlsrv_send_stream_data( resource $stmt ) -

Provides information about the server.

sqlsrv_server_info( resource $conn ) mysql_get_server_info ([ resource $link_identifier ] )