Merge branch 'dev' of https://github.com/Microsoft/msphpsql into dev
This commit is contained in:
commit
e49bb5cc8a
21
CHANGELOG.md
21
CHANGELOG.md
|
@ -3,6 +3,27 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
|
||||
## Windows/Linux/MAC 5.0.0-preview - 2017-07-31
|
||||
Updated PECL release packages. Here is the list of updates:
|
||||
|
||||
### Added
|
||||
- Added support for PHP 7.2 Beta 1
|
||||
|
||||
### Changed
|
||||
- Implementation of PDO::lastInsertId($name) to return the last inserted sequence number if the sequence name is supplied to the function ([lastInsertId](https://github.com/Microsoft/msphpsql/wiki/Features#lastinsertid))
|
||||
|
||||
### Removed
|
||||
- No longer support Ubuntu 15
|
||||
- Supplying tablename into PDO::lastInsertId($name) no longer return the last inserted row ([lastInsertId](https://github.com/Microsoft/msphpsql/wiki/Features#lastinsertid))
|
||||
|
||||
### Limitation
|
||||
- No support for inout / output params when using sql_variant type
|
||||
|
||||
### Known Issues
|
||||
- When pooling is enabled in Linux or MAC
|
||||
- unixODBC <= 2.3.4 (Linux and MAC) might not return proper diagnostics information, such as error messages, warnings and informative messages
|
||||
- due to this unixODBC bug, fetch large data (such as xml, binary) as streams as a workaround. See the examples [here](https://github.com/Microsoft/msphpsql/wiki/Connection-Pooling-on-Linux-and-Mac)
|
||||
|
||||
## Windows/Linux/MAC 4.3.0 - 2017-07-06
|
||||
Production Ready release for SQLSRV and PDO_SQLSRV drivers on Sierra, El Capitan, Debian 8, Ubuntu 15, Ubuntu 16, CentOS 7, and Windows. Here is the changlog since the last Production Ready release.
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ Thank you for taking time to take our February survey. Let us know how we are do
|
|||
|-------------------------|--------------------------| ------------------
|
||||
| [![av-image][]][av-site]| [![tv-image][]][tv-site] |[![Coverage Status][]][coveralls-site]
|
||||
|
||||
[av-image]: https://ci.appveyor.com/api/projects/status/github/Microsoft/msphpsql?branch=dev&svg=true
|
||||
[av-site]: https://ci.appveyor.com/project/Microsoft-PHPSQL/msphpsql
|
||||
[av-image]: https://ci.appveyor.com/api/projects/status/xhp4nq9ouljnhxqf/branch/dev?svg=true
|
||||
[av-site]: https://ci.appveyor.com/project/Microsoft-PHPSQL/msphpsql-frhmr/branch/dev
|
||||
[tv-image]: https://travis-ci.org/Microsoft/msphpsql.svg?branch=dev
|
||||
[tv-site]: https://travis-ci.org/Microsoft/msphpsql/
|
||||
[Coverage Status]: https://coveralls.io/repos/github/Microsoft/msphpsql/badge.svg?branch=dev
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: JScript build configuration used by buildconf.bat
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Implements the PDO object for PDO_SQLSRV
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
@ -30,8 +30,8 @@ namespace {
|
|||
|
||||
const char LAST_INSERT_ID_QUERY[] = "SELECT @@IDENTITY;";
|
||||
const size_t LAST_INSERT_ID_BUFF_LEN = 10; // size of the buffer to hold the string value of the last insert id integer
|
||||
const char TABLE_LAST_INSERT_ID_QUERY[] = "SELECT IDENT_CURRENT(%s)";
|
||||
const int LAST_INSERT_ID_QUERY_MAX_LEN = sizeof( TABLE_LAST_INSERT_ID_QUERY ) + SQL_MAX_SQLSERVERNAME + 2; // include the quotes
|
||||
const char SEQUENCE_CURRENT_VALUE_QUERY[] = "SELECT CURRENT_VALUE FROM SYS.SEQUENCES WHERE NAME=%s";
|
||||
const int LAST_INSERT_ID_QUERY_MAX_LEN = sizeof( SEQUENCE_CURRENT_VALUE_QUERY ) + SQL_MAX_SQLSERVERNAME + 2; // include the quotes
|
||||
|
||||
// List of PDO supported connection options.
|
||||
namespace PDOConnOptionNames {
|
||||
|
@ -1235,7 +1235,7 @@ char * pdo_sqlsrv_dbh_last_id( _Inout_ pdo_dbh_t *dbh, _In_z_ const char *name,
|
|||
size_t quoted_len = 0;
|
||||
int quoted = pdo_sqlsrv_dbh_quote( dbh, name, strlen( name ), "ed_table, "ed_len, PDO_PARAM_NULL TSRMLS_CC );
|
||||
SQLSRV_ASSERT( quoted, "PDO::lastInsertId failed to quote the table name.");
|
||||
snprintf( last_insert_id_query, LAST_INSERT_ID_QUERY_MAX_LEN, TABLE_LAST_INSERT_ID_QUERY, quoted_table );
|
||||
snprintf( last_insert_id_query, LAST_INSERT_ID_QUERY_MAX_LEN, SEQUENCE_CURRENT_VALUE_QUERY, quoted_table );
|
||||
sqlsrv_free( quoted_table );
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: initialization routines for PDO_SQLSRV
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//
|
||||
// Copyright Microsoft Corporation
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Implements the PDOStatement object for the PDO_SQLSRV
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Utility functions used by both connection or statement functions
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//
|
||||
// Contents: Declarations for the extension
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Version resource
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
// Contents: Contains functions for handling Windows format strings
|
||||
// and UTF-16 on non-Windows platforms
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// Contents: Contains functions for handling Windows format strings
|
||||
// and UTF-16 on non-Windows platforms
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Contains functions for handling UTF-16 on non-Windows platforms
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Contains functions for handling UTF-16 on non-Windows platforms
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Core routines that use connection handles shared between sqlsrv and pdo_sqlsrv
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: common initialization routines shared by PDO and sqlsrv
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Result sets
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//
|
||||
// Contents: Core routines and constants shared by the Microsoft Drivers for PHP for SQL Server
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Core routines that use statement handles shared between sqlsrv and pdo_sqlsrv
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Implementation of PHP streams for reading SQL Server data
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//
|
||||
// Comments: Mostly error handling and some type handling
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// Contents: Contains functions for handling Windows format strings
|
||||
// and UTF-16 on non-Windows platforms
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// Contents: Contains a portable abstraction for interlocked, atomic
|
||||
// operations on int32_t and pointer types.
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// Contents: Contains a portable abstraction for interlocked, atomic
|
||||
// operations on int32_t and pointer types.
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// Contents: Contains a portable abstraction for interlocked, singly
|
||||
// linked list.
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Contains portable classes for localization
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Must be included in one c/cpp file per binary
|
||||
// A build error will occur if this inclusion policy is not followed
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
// pecuniary loss) arising out of the use of or inability to use
|
||||
// this SDK, even if Microsoft has been advised of the possibility
|
||||
// of such damages.
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Contains the minimal definitions to build on non-Windows platforms
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//---------------------------------------------------------------------------------------------------------------------------------
|
||||
// File: typedefs_for_linux.h
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// File: version.h
|
||||
// Contents: Version number constants
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
@ -26,8 +26,8 @@
|
|||
// Increase Major number with backward incompatible breaking changes.
|
||||
// Increase Minor with backward compatible new functionalities and API changes.
|
||||
// Increase Patch for backward compatible fixes.
|
||||
#define SQLVERSION_MAJOR 4
|
||||
#define SQLVERSION_MINOR 3
|
||||
#define SQLVERSION_MAJOR 5
|
||||
#define SQLVERSION_MINOR 0
|
||||
#define SQLVERSION_PATCH 0
|
||||
#define SQLVERSION_BUILD 0
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
|||
// for stable releases should be empty
|
||||
// "-RC" for release candidates
|
||||
// "-preview" for ETP
|
||||
#define SEMVER_PRERELEASE
|
||||
#define SEMVER_PRERELEASE "preview"
|
||||
// Semantic versioning build metadata, build meta data is not counted in precedence order.
|
||||
#define SEMVER_BUILDMETA
|
||||
|
||||
|
@ -47,8 +47,10 @@
|
|||
// Main version, dot separated 3 digits, Major.Minor.Patch
|
||||
#define VER_APIVERSION_STR STRINGIFY( SQLVERSION_MAJOR ) "." STRINGIFY( SQLVERSION_MINOR ) "." STRINGIFY( SQLVERSION_PATCH )
|
||||
|
||||
// Remove "-" if SEMVER_PRERELEASE is empty (for stable releases)
|
||||
#define VER_FILEVERSION_STR VER_APIVERSION_STR SEMVER_PRERELEASE SEMVER_BUILDMETA
|
||||
// For preview release, we want the following:
|
||||
// #define VER_FILEVERSION_STR VER_APIVERSION_STR "-" SEMVER_PRERELEASE SEMVER_BUILDMETA
|
||||
// because pecl doesn't like dashes. However, if SEMVER_PRERELEASE is empty, the "-" must be removed
|
||||
#define VER_FILEVERSION_STR VER_APIVERSION_STR "-" SEMVER_PRERELEASE SEMVER_BUILDMETA
|
||||
#define _FILEVERSION SQLVERSION_MAJOR,SQLVERSION_MINOR,SQLVERSION_PATCH,SQLVERSION_BUILD
|
||||
|
||||
// PECL package version macros (can't have '-' or '+')
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: include for definition of Windows types for non-Windows platforms
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// Contents: This module defines helper functions to prevent
|
||||
// integer overflow bugs.
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Contains the minimal definitions to build on non-Windows platforms
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Contains the minimal definitions to build on non-Windows platforms
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: JScript build configuration used by buildconf.bat
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Routines that use connection handles
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// File: init.cpp
|
||||
// Contents: initialization routines for the extension
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
//
|
||||
// Comments: Also contains "internal" declarations shared across source files.
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Routines that use statement handles
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
// Contents: Version resource
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//
|
||||
// Comments: Mostly error handling and some type handling
|
||||
//
|
||||
// Microsoft Drivers 4.3 for PHP for SQL Server
|
||||
// Microsoft Drivers 5.0 for PHP for SQL Server
|
||||
// Copyright(c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// MIT License
|
||||
|
|
61
test/functional/pdo_sqlsrv/pdo_278_lastinsertid_seq.phpt
Normal file
61
test/functional/pdo_sqlsrv/pdo_278_lastinsertid_seq.phpt
Normal file
|
@ -0,0 +1,61 @@
|
|||
--TEST--
|
||||
Provide name in lastInsertId to retrieve the last sequence number
|
||||
--SKIPIF--
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("MsCommon.inc");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try{
|
||||
$database = "tempdb";
|
||||
$conn = new PDO("sqlsrv:Server=$server;Database=$databaseName", $uid, $pwd);
|
||||
|
||||
// sequence is only supported in SQL server 2012 and up (or version 11 and up)
|
||||
// Output Done once the server version is found to be < 11
|
||||
$version_arr = explode(".", $conn->getAttribute(PDO::ATTR_SERVER_VERSION));
|
||||
if ($version_arr[0] < 11) {
|
||||
echo "Done\n";
|
||||
}
|
||||
else {
|
||||
$tableName1 = GetTempTableName('tab1', false);
|
||||
$tableName2 = GetTempTableName('tab2', false);
|
||||
$sequenceName = 'sequence1';
|
||||
|
||||
$stmt = $conn->query("IF OBJECT_ID('$sequenceName', 'SO') IS NOT NULL DROP SEQUENCE $sequenceName");
|
||||
$sql = "CREATE TABLE $tableName1 (seqnum INTEGER NOT NULL PRIMARY KEY, SomeNumber INT)";
|
||||
$stmt = $conn->query($sql);
|
||||
$sql = "CREATE TABLE $tableName2 (ID INT IDENTITY(1,2), SomeValue char(10))";
|
||||
$stmt = $conn->query($sql);
|
||||
|
||||
$sql = "CREATE SEQUENCE $sequenceName AS INTEGER START WITH 1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 100 CYCLE";
|
||||
$stmt = $conn->query($sql);
|
||||
|
||||
$ret = $conn->exec("INSERT INTO $tableName1 VALUES( NEXT VALUE FOR $sequenceName, 20 )");
|
||||
$ret = $conn->exec("INSERT INTO $tableName1 VALUES( NEXT VALUE FOR $sequenceName, 40 )");
|
||||
$ret = $conn->exec("INSERT INTO $tableName1 VALUES( NEXT VALUE FOR $sequenceName, 60 )");
|
||||
$ret = $conn->exec("INSERT INTO $tableName2 VALUES( '20' )");
|
||||
// return the last sequence number is sequence name is provided
|
||||
$lastSeq = $conn->lastInsertId($sequenceName);
|
||||
// defaults to $tableName2 -- because it returns the last inserted id value
|
||||
$lastRow = $conn->lastInsertId();
|
||||
|
||||
if ($lastSeq == 3 && $lastRow == 1) {
|
||||
echo "Done\n";
|
||||
}
|
||||
else {
|
||||
echo "sequence value or identity does not match as expected\n";
|
||||
}
|
||||
$stmt = $conn->query("DROP TABLE $tableName1");
|
||||
$stmt = $conn->query("DROP TABLE $tableName2");
|
||||
$stmt = $conn->query("DROP SEQUENCE $sequenceName");
|
||||
$stmt = null;
|
||||
}
|
||||
$conn = null;
|
||||
}
|
||||
catch (Exception $e){
|
||||
echo "Exception $e\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Done
|
64
test/functional/pdo_sqlsrv/pdo_278_lastinsertid_seq_2.phpt
Normal file
64
test/functional/pdo_sqlsrv/pdo_278_lastinsertid_seq_2.phpt
Normal file
|
@ -0,0 +1,64 @@
|
|||
--TEST--
|
||||
LastInsertId returns the last sequences operating on the same table
|
||||
--SKIPIF--
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("MsCommon.inc");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try{
|
||||
$database = "tempdb";
|
||||
$conn = new PDO("sqlsrv:Server=$server;Database=$databaseName", $uid, $pwd);
|
||||
|
||||
// sequence is only supported in SQL server 2012 and up (or version 11 and up)
|
||||
// Output Done once the server version is found to be < 11
|
||||
$version_arr = explode(".", $conn->getAttribute(PDO::ATTR_SERVER_VERSION));
|
||||
if ($version_arr[0] < 11) {
|
||||
echo "Done\n";
|
||||
}
|
||||
else {
|
||||
$tableName = GetTempTableName('tab', false);
|
||||
$sequence1 = 'sequence1';
|
||||
$sequence2 = 'sequenceNeg1';
|
||||
$stmt = $conn->query("IF OBJECT_ID('$sequence1', 'SO') IS NOT NULL DROP SEQUENCE $sequence1");
|
||||
$stmt = $conn->query("IF OBJECT_ID('$sequence2', 'SO') IS NOT NULL DROP SEQUENCE $sequence2");
|
||||
$sql = "CREATE TABLE $tableName (ID INT IDENTITY(1,1), SeqNumInc INTEGER NOT NULL PRIMARY KEY, SomeNumber INT)";
|
||||
$stmt = $conn->query($sql);
|
||||
$sql = "CREATE SEQUENCE $sequence1 AS INTEGER START WITH 1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 100";
|
||||
$stmt = $conn->query($sql);
|
||||
|
||||
$sql = "CREATE SEQUENCE $sequence2 AS INTEGER START WITH 200 INCREMENT BY -1 MINVALUE 101 MAXVALUE 200";
|
||||
$stmt = $conn->query($sql);
|
||||
$ret = $conn->exec("INSERT INTO $tableName VALUES( NEXT VALUE FOR $sequence1, 20 )");
|
||||
$ret = $conn->exec("INSERT INTO $tableName VALUES( NEXT VALUE FOR $sequence2, 180 )");
|
||||
$ret = $conn->exec("INSERT INTO $tableName VALUES( NEXT VALUE FOR $sequence1, 40 )");
|
||||
$ret = $conn->exec("INSERT INTO $tableName VALUES( NEXT VALUE FOR $sequence2, 160 )");
|
||||
$ret = $conn->exec("INSERT INTO $tableName VALUES( NEXT VALUE FOR $sequence1, 60 )");
|
||||
$ret = $conn->exec("INSERT INTO $tableName VALUES( NEXT VALUE FOR $sequence2, 140 )");
|
||||
// return the last sequence number of 'sequence1'
|
||||
$lastSeq1 = $conn->lastInsertId($sequence1);
|
||||
|
||||
// return the last sequence number of 'sequenceNeg1'
|
||||
$lastSeq2 = $conn->lastInsertId($sequence2);
|
||||
|
||||
// providing a table name in lastInsertId should return an empty string
|
||||
$lastSeq3 = $conn->lastInsertId($tableName);
|
||||
|
||||
if ($lastSeq1 == 3 && $lastSeq2 == 198 && $lastSeq3 == "") {
|
||||
echo "Done\n";
|
||||
}
|
||||
|
||||
$stmt = $conn->query("DROP TABLE $tableName");
|
||||
$stmt = $conn->query("DROP SEQUENCE $sequence1");
|
||||
$stmt = $conn->query("DROP SEQUENCE $sequence2");
|
||||
$stmt = null;
|
||||
}
|
||||
$conn = null;
|
||||
}
|
||||
catch (Exception $e){
|
||||
echo "Exception $e\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Done
|
|
@ -36,7 +36,7 @@ function ConnectionTest()
|
|||
Trace("\nValid connection attempt (to $server) ....\n");
|
||||
$conn2 = Connect();
|
||||
$errors = sqlsrv_errors(SQLSRV_ERR_ERRORS);
|
||||
if(count($errors) != 0)
|
||||
if (!empty($errors))
|
||||
{
|
||||
die("No errors were expected on valid connection attempts.");
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -72,7 +72,7 @@ function FetchField($stmt, $idx, $numFields, $errorExpected)
|
|||
function PrintError($errorExpected = true)
|
||||
{
|
||||
$errors = sqlsrv_errors(SQLSRV_ERR_ALL);
|
||||
if (count($errors) > 0)
|
||||
if (!empty($errors))
|
||||
{
|
||||
$e = $errors[0];
|
||||
var_dump($e['message']);
|
||||
|
|
|
@ -52,7 +52,7 @@ sqlsrv_close($conn);
|
|||
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
Notice\: Use of undefined constant SQLSRV_ENC_UNKNOWN - assumed \'SQLSRV_ENC_UNKNOWN\' in .+(\/|\\)sqlsrv_input_param_unknown_encoding\.php on line 26
|
||||
(Warning|Notice)\: Use of undefined constant SQLSRV_ENC_UNKNOWN - assumed \'SQLSRV_ENC_UNKNOWN\' (\(this will throw an Error in a future version of PHP\) )?in .+(\/|\\)sqlsrv_input_param_unknown_encoding\.php on line 26
|
||||
Array
|
||||
\(
|
||||
\[0\] => Array
|
||||
|
@ -67,7 +67,7 @@ Array
|
|||
|
||||
\)
|
||||
|
||||
Notice\: Use of undefined constant SQLSRV_ENC_UNKNOWN - assumed \'SQLSRV_ENC_UNKNOWN\' in .+(\/|\\)sqlsrv_input_param_unknown_encoding\.php on line 33
|
||||
(Warning|Notice)\: Use of undefined constant SQLSRV_ENC_UNKNOWN - assumed \'SQLSRV_ENC_UNKNOWN\' (\(this will throw an Error in a future version of PHP\) )?in .+(\/|\\)sqlsrv_input_param_unknown_encoding\.php on line 33
|
||||
Array
|
||||
\(
|
||||
\[0\] => Array
|
||||
|
@ -81,4 +81,3 @@ Array
|
|||
\)
|
||||
|
||||
\)
|
||||
|
||||
|
|
Loading…
Reference in a new issue