Another batch of tests
This commit is contained in:
parent
489d3e8018
commit
ea83d94250
|
@ -7,15 +7,12 @@ false as a bit, a true value cast to a bit, a true value as an int.
|
|||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
<?php require('skipif_versions_old.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
$conn = connect();
|
||||
if (!$conn) {
|
||||
fatalError("Could not connect");
|
||||
}
|
||||
$conn = AE\connect();
|
||||
|
||||
$stmt = sqlsrv_query($conn, "IF OBJECT_ID('testBoolean', 'P') IS NOT NULL DROP PROCEDURE testBoolean");
|
||||
|
||||
|
@ -41,15 +38,21 @@ $bit_true = 0;
|
|||
$bit_false = 1;
|
||||
$bit_cast_true = 0;
|
||||
$int_true = 0;
|
||||
$params = array(array(&$bit_true, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT), array(&$bit_false, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT), array(&$bit_cast_true, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT), array(&$int_true, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT));
|
||||
$sqlType = AE\isColEncrypted() ? SQLSRV_SQLTYPE_BIT : null;
|
||||
$params = array(array(&$bit_true, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT, $sqlType), array(&$bit_false, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT, $sqlType), array(&$bit_cast_true, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT, $sqlType), array(&$int_true, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT, $sqlType));
|
||||
|
||||
$stmt = sqlsrv_query($conn, $callSP, $params);
|
||||
if (! $stmt){
|
||||
fatalError("Failed when calling testBoolean.");
|
||||
}
|
||||
|
||||
var_dump($bit_true);
|
||||
var_dump($bit_false);
|
||||
var_dump($bit_cast_true);
|
||||
var_dump($int_true);
|
||||
|
||||
$stmt = sqlsrv_query($conn, "DROP PROCEDURE testBoolean");
|
||||
|
||||
sqlsrv_free_stmt($stmt);
|
||||
sqlsrv_close($conn);
|
||||
?>
|
||||
|
|
|
@ -7,15 +7,12 @@ false as a bool, a true value cast to a bool, a true value as an bool.
|
|||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
<?php require('skipif_versions_old.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
$conn = Connect();
|
||||
if( !$conn ) {
|
||||
fatalError("Could not connect");
|
||||
}
|
||||
$conn = AE\connect();
|
||||
|
||||
$stmt = sqlsrv_query($conn, "IF OBJECT_ID('testBoolean', 'P') IS NOT NULL DROP PROCEDURE testBoolean");
|
||||
|
||||
|
@ -41,15 +38,22 @@ $bit_true = false;
|
|||
$bit_false = true;
|
||||
$bit_cast_true = false;
|
||||
$int_true = false;
|
||||
$params = array(array(&$bit_true, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT), array(&$bit_false, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT), array(&$bit_cast_true, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT), array(&$int_true, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT));
|
||||
|
||||
$sqlType = AE\isColEncrypted() ? SQLSRV_SQLTYPE_BIT : null;
|
||||
$params = array(array(&$bit_true, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT, $sqlType), array(&$bit_false, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT, $sqlType), array(&$bit_cast_true, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT, $sqlType), array(&$int_true, SQLSRV_PARAM_INOUT, SQLSRV_PHPTYPE_INT, $sqlType));
|
||||
|
||||
$stmt = sqlsrv_query($conn, $callSP, $params);
|
||||
if (! $stmt){
|
||||
fatalError("Failed when calling testBoolean.");
|
||||
}
|
||||
|
||||
var_dump($bit_true);
|
||||
var_dump($bit_false);
|
||||
var_dump($bit_cast_true);
|
||||
var_dump($int_true);
|
||||
|
||||
$stmt = sqlsrv_query($conn, "DROP PROCEDURE testBoolean");
|
||||
|
||||
sqlsrv_free_stmt($stmt);
|
||||
sqlsrv_close($conn);
|
||||
?>
|
||||
|
|
|
@ -7,17 +7,12 @@ false as a bit, a true value cast to a bit, a true value as an int.
|
|||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
<?php require('skipif_versions_old.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Fails on PHP 7, producing 1's and 2's instead of 0's and 1's. */
|
||||
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
$conn = Connect();
|
||||
if (!$conn) {
|
||||
fatalError("Could not connect");
|
||||
}
|
||||
$conn = AE\connect();
|
||||
|
||||
$stmt = sqlsrv_query($conn, "IF OBJECT_ID('testBoolean', 'P') IS NOT NULL DROP PROCEDURE testBoolean");
|
||||
|
||||
|
@ -43,15 +38,22 @@ $bit_true = 0;
|
|||
$bit_false = 0;
|
||||
$bit_cast_true = 0;
|
||||
$int_true = 0;
|
||||
$params = array(array(&$bit_true, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT), array(&$bit_false, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT), array(&$bit_cast_true, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT), array(&$int_true, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT));
|
||||
|
||||
$sqlType = AE\isColEncrypted() ? SQLSRV_SQLTYPE_BIT : null;
|
||||
$params = array(array(&$bit_true, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT, $sqlType), array(&$bit_false, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT, $sqlType), array(&$bit_cast_true, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT, $sqlType), array(&$int_true, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT, $sqlType));
|
||||
|
||||
$stmt = sqlsrv_query($conn, $callSP, $params);
|
||||
if (! $stmt){
|
||||
fatalError("Failed when calling testBoolean.");
|
||||
}
|
||||
|
||||
var_dump($bit_true);
|
||||
var_dump($bit_false);
|
||||
var_dump($bit_cast_true);
|
||||
var_dump($int_true);
|
||||
|
||||
$stmt = sqlsrv_query($conn, "DROP PROCEDURE testBoolean");
|
||||
|
||||
sqlsrv_free_stmt($stmt);
|
||||
sqlsrv_close($conn);
|
||||
?>
|
||||
|
|
|
@ -7,17 +7,12 @@ false as a bool, a true value cast to a bool, a true value as an bool.
|
|||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
<?php require('skipif_versions_old.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Fails on PHP 7, producing 1's and 2's instead of 0's and 1's. */
|
||||
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
$conn = Connect();
|
||||
if (!$conn) {
|
||||
fatalError("Could not connect");
|
||||
}
|
||||
$conn = AE\connect();
|
||||
|
||||
$stmt = sqlsrv_query($conn, "IF OBJECT_ID('testBoolean', 'P') IS NOT NULL DROP PROCEDURE testBoolean");
|
||||
|
||||
|
@ -43,15 +38,22 @@ $bit_true = false;
|
|||
$bit_false = false;
|
||||
$bit_cast_true = false;
|
||||
$int_true = false;
|
||||
$params = array(array(&$bit_true, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT), array(&$bit_false, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT), array(&$bit_cast_true, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT), array(&$int_true, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT));
|
||||
|
||||
$sqlType = AE\isColEncrypted() ? SQLSRV_SQLTYPE_BIT : null;
|
||||
$params = array(array(&$bit_true, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT, $sqlType), array(&$bit_false, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT, $sqlType), array(&$bit_cast_true, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT, $sqlType), array(&$int_true, SQLSRV_PARAM_OUT, SQLSRV_PHPTYPE_INT, $sqlType));
|
||||
|
||||
$stmt = sqlsrv_query($conn, $callSP, $params);
|
||||
if (! $stmt){
|
||||
fatalError("Failed when calling testBoolean.");
|
||||
}
|
||||
|
||||
var_dump($bit_true);
|
||||
var_dump($bit_false);
|
||||
var_dump($bit_cast_true);
|
||||
var_dump($int_true);
|
||||
|
||||
$stmt = sqlsrv_query($conn, "DROP PROCEDURE testBoolean");
|
||||
|
||||
sqlsrv_free_stmt($stmt);
|
||||
sqlsrv_close($conn);
|
||||
?>
|
||||
|
|
|
@ -1,23 +1,69 @@
|
|||
--TEST--
|
||||
Test a complex query with IDENTITY_INSERT
|
||||
--DESCRIPTION--
|
||||
Verifies the behavior of INSERT queries with and without the IDENTITY flag set.
|
||||
This test is similar to the other test TC33_ComplexQuery but using UTF-8 data
|
||||
--SKIPIF--
|
||||
<?php require('skipif_versions_old.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
function ComplexQuery()
|
||||
function insertTest($conn, $tableName, $inputs, $query = null)
|
||||
{
|
||||
$stmt = null;
|
||||
if (!AE\isColEncrypted()) {
|
||||
$insertSql = AE\getInsertSqlComplete($tableName, $inputs);
|
||||
if (! is_null($query)) {
|
||||
$sql = str_replace("SQL", $insertSql, $query);
|
||||
} else {
|
||||
$sql = $insertSql;
|
||||
}
|
||||
$stmt = sqlsrv_query($conn, $sql);
|
||||
} else {
|
||||
// must bind parameters
|
||||
$insertSql = AE\getInsertSqlPlaceholders($tableName, $inputs);
|
||||
$params = array();
|
||||
foreach ($inputs as $key => $input) {
|
||||
array_push($params, $inputs[$key]);
|
||||
}
|
||||
if (! is_null($query)) {
|
||||
// this contains a batch of sql statements,
|
||||
// with set identity_insert on or off
|
||||
// thus, sqlsrv_query should be called
|
||||
$sql = str_replace("SQL", $insertSql, $query);
|
||||
$stmt = sqlsrv_query($conn, $sql, $params);
|
||||
} else {
|
||||
// just a regular insert, so use sqlsrv_prepare
|
||||
$sql = $insertSql;
|
||||
$stmt = sqlsrv_prepare($conn, $sql, $params);
|
||||
if ($stmt) {
|
||||
sqlsrv_execute($stmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
function complexQuery()
|
||||
{
|
||||
set_time_limit(0);
|
||||
sqlsrv_configure('WarningsReturnAsErrors', 1);
|
||||
|
||||
// Connect
|
||||
$conn = connect(array("CharacterSet"=>"UTF-8"));
|
||||
if (!$conn) {
|
||||
fatalError("Could not connect.\n");
|
||||
$conn = AE\connect(array("CharacterSet"=>"UTF-8"));
|
||||
|
||||
$tableName = 'complex_query_test';
|
||||
$columns = array(new AE\ColumnMeta('int', 'c1_int', "IDENTITY"),
|
||||
new AE\ColumnMeta('tinyint', 'c2_tinyint'),
|
||||
new AE\ColumnMeta('smallint', 'c3_smallint'),
|
||||
new AE\ColumnMeta('bigint', 'c4_bigint'),
|
||||
new AE\ColumnMeta('varchar(512)', 'c5_varchar'));
|
||||
$stmt = AE\createTable($conn, $tableName, $columns);
|
||||
if (!$stmt) {
|
||||
fatalError("Failed to create table $tableName\n");
|
||||
}
|
||||
|
||||
$tableName = GetTempTableName();
|
||||
|
||||
$stmt = sqlsrv_query($conn, "CREATE TABLE $tableName ([c1_int] int IDENTITY, [c2_tinyint] tinyint, [c3_smallint] smallint, [c4_bigint] bigint, [c5_varchar] varchar(512))");
|
||||
sqlsrv_free_stmt($stmt);
|
||||
|
||||
$noExpectedRows = 0;
|
||||
|
@ -26,12 +72,16 @@ function ComplexQuery()
|
|||
sqlsrv_free_stmt($stmt);
|
||||
$noExpectedRows++;
|
||||
|
||||
$stmt = sqlsrv_query($conn, "INSERT INTO $tableName (c1_int, c2_tinyint, c3_smallint, c4_bigint, c5_varchar) VALUES (1324944463, 105, 18521, 2022363960, 'üv£ª©*@*rãCaC|/ä*,,@ý©bvªäîCUBão_+ßZhUªî¢~ÖÜ/ª@ä+ßßar~Özr,aß/,bCaü<ÖÐhÐbß<î/ðzãý+bÜ:Zßöüª@BÖUß<U@¢Ö<hÖhubÄrÐÃ*.å|a/,ª¢ßOa@oubýãýý£îZ~,ä¢î|+ª¢rZUCrOu,B£åß|:£ªîoBärÐA/BzOoß<bvu~ßuîCãߢ¢îýA@aðuAa,UÐ.>Ußaåab|¢ª¢|ü£/ÃßzzuªãA.ªZUöß<©a>OzübBüÜ|bZ./öbvß*rbö>ß©r//~ÖCÜhð¢bßz:¢Ä+_Ã__£ý£Uýh:v¢bý,©Ü£©,A:Zh>ßåvö+Ä>Ã.ßvC|:Ü*Üü*åz|b.©©üAý@uU.oOÜýAÜÐÜð©OB|rrîbU<övoUßäZÃÖ<ÄåªAÄ.Ua*ÖOªB,åîzB:ÜhövÖZhýðüC')");
|
||||
$inputs = array("c1_int" => 1324944463, "c2_tinyint" => 105, "c3_smallint" => 18521, "c4_bigint" => 2022363960, "c5_varchar" => "üv£ª©*@*rãCaC|/ä*,,@ý©bvªäîCUBão_+ßZhUªî¢~ÖÜ/ª@ä+ßßar~Özr,aß/,bCaü<ÖÐhÐbß<î/ðzãý+bÜ:Zßöüª@BÖUß<U@¢Ö<hÖhubÄrÐÃ*.å|a/,ª¢ßOa@oubýãýý£îZ~,ä¢î|+ª¢rZUCrOu,B£åß|:£ªîoBärÐA/BzOoß<bvu~ßuîCãߢ¢îýA@aðuAa,UÐ.>Ußaåab|¢ª¢|ü£/ÃßzzuªãA.ªZUöß<©a>OzübBüÜ|bZ./öbvß*rbö>ß©r//~ÖCÜhð¢bßz:¢Ä+_Ã__£ý£Uýh:v¢bý,©Ü£©,A:Zh>ßåvö+Ä>Ã.ßvC|:Ü*Üü*åz|b.©©üAý@uU.oOÜýAÜÐÜð©OB|rrîbU<övoUßäZÃÖ<ÄåªAÄ.Ua*ÖOªB,åîzB:ÜhövÖZhýðüC");
|
||||
$stmt = AE\insertRow($conn, $tableName, $inputs);
|
||||
unset($inputs);
|
||||
sqlsrv_free_stmt($stmt);
|
||||
|
||||
$stmt = sqlsrv_query($conn, "SET IDENTITY_INSERT $tableName OFF;");
|
||||
sqlsrv_free_stmt($stmt);
|
||||
$stmt = sqlsrv_query($conn, "INSERT INTO $tableName (c1_int, c2_tinyint, c3_smallint, c4_bigint, c5_varchar) VALUES (-1554807493, 253, -12809, -1698802997, 'ßöîÄ@v+oß+î|ruý*Ü¢ãÖ~.*ArABªßOBzUU£ßUuÜ<ðýr|b~_äaü/OÖzv.¢ä>>OÜ+¢vªzöªoB_ä+ߪrÜö£>U~ãÖð~ðýur,ÖvZh¢ªZ>vªUäåîz,>ÃräðäýðO_ä*a,ö+üÐß~bÃü¢<<+îýÐöäªO/zA+:îZ,öBÐü<î£îåhBÖzßÄ~,:>bð<~aÐãö¢*¢våvÃÐåî@a<vBãßÖä媢<üa.u:>_Äu£öa~våu>¢Bã©å:Aßã£Üvåö+aä£U<bUu*rv+@U_|ð@+v@Üßb|,.ªäÖ/*êýÄ¢¢Ö/+ä><¢b@|zbãÖ@ÃãUb|ÄB£©,~ßð©ðUßöZÜöî£Zz<>åäZßð©ßaÖÖ¢bð£ßÄ>îÃÃ.~z>h_ý~ÜrüÖBruß+ª©CB©O>rå,Chro,£ßbZ_ß©,ÃUu|ßåüÄ/ý*åu|~Ö.ßZUoä:~A~CZhðU|öZ:ä/£Ä*î©ÄhävhbrzîÐ@.rãß©@uÜ©~>ÖÜööCÄzÜCü+>oZÄÜ/ABßA_b|b¢bÜh<|uBr.B*rü>aCª|AÄ©@öÖßÖ~Ö<rÐ,ä@©|££.C.üå¢/rbªßî')");
|
||||
$inputs = array("c1_int" => -1554807493, "c2_tinyint" => 253, "c3_smallint" => -12809, "c4_bigint" => -1698802997, "c5_varchar" => "ßöîÄ@v+oß+î|ruý*Ü¢ãÖ~.*ArABªßOBzUU£ßUuÜ<ðýr|b~_äaü/OÖzv.¢ä>>OÜ+¢vªzöªoB_ä+ߪrÜö£>U~ãÖð~ðýur,ÖvZh¢ªZ>vªUäåîz,>ÃräðäýðO_ä*a,ö+üÐß~bÃü¢<<+îýÐöäªO/zA+:îZ,öBÐü<î£îåhBÖzßÄ~,:>bð<~aÐãö¢*¢våvÃÐåî@a<vBãßÖä媢<üa.u:>_Äu£öa~våu>¢Bã©å:Aßã£Üvåö+aä£U<bUu*rv+@U_|ð@+v@Üßb|,.ªäÖ/*êýÄ¢¢Ö/+ä><¢b@|zbãÖ@ÃãUb|ÄB£©,~ßð©ðUßöZÜöî£Zz<>åäZßð©ßaÖÖ¢bð£ßÄ>îÃÃ.~z>h_ý~ÜrüÖBruß+ª©CB©O>rå,Chro,£ßbZ_ß©,ÃUu|ßåüÄ/ý*åu|~Ö.ßZUoä:~A~CZhðU|öZ:ä/£Ä*î©ÄhävhbrzîÐ@.rãß©@uÜ©~>ÖÜööCÄzÜCü+>oZÄÜ/ABßA_b|b¢bÜh<|uBr.B*rü>aCª|AÄ©@öÖßÖ~Ö<rÐ,ä@©|££.C.üå¢/rbªßî");
|
||||
$stmt = AE\insertRow($conn, $tableName, $inputs);
|
||||
unset($inputs);
|
||||
|
||||
$errors = sqlsrv_errors(SQLSRV_ERR_ALL);
|
||||
$count1 = count($errors);
|
||||
|
@ -44,7 +94,20 @@ function ComplexQuery()
|
|||
print "$value3\n";
|
||||
$noExpectedRows++;
|
||||
|
||||
$stmt = sqlsrv_query($conn, "SET IDENTITY_INSERT $tableName ON;INSERT INTO $tableName (c1_int, c2_tinyint, c3_smallint, c4_bigint, c5_varchar) VALUES (1994559593, 129, -8455, -236232445, 'ߣ*ÐO+ö+<ã:>üoîzÄ¢zz~Ãýö|vUå>|CÄUü~>buÃv<ä~Ö+.ü*ªbuî_bBC©.oîCbåîÐÖUa~/U>öAäÐBu~ozîZ/zrOOä:ß©bßo.ü©A¢höÖoßÖü>r+A/ßaªrß:ª@|bhhªª/oå<Ö:rüa+oC¢~uÄü>/.ãbOöª_b@bbߢ|uzߪ֢~uäýub©ãaZäC£ÄrÖ,üöäu+Ãîö|||,U.BråãoýbüåöÃburöoî+>öä©î,u_öb©@C:ÜåÜîÜåAÖzýbð|Z<Ãý.£rîZ|/z@¢£AýZ,ßuZ*:b.AzТä¢üßöbvbväð|<**~Uv.Ð*Ä©B*ýCUöa¢åO©Ãß*ÃÃ|ÜðA@îÃßaB<hÜîaZoöå>öüahUUA+ߣ_u|~äö.©hr£oBo<äãüO+_å<OЪÖßßväzA,~u~Obbî@ßÃãÜää©,.bO:C£Ü,äUO¢åå**hÐ~UZ©ðh<abß*üÖîC.äßh~Uð<r*ßäv£î*@¢Cv/BÖhAüB~ýAå@Z@<a_O|<©ßb*CZO,o:ã+¢£ÃZC©B¢o+>O:Z~Üoîßzb£ª£A.AÖÜÄ._O_å£ß');SET IDENTITY_INSERT $tableName OFF;");
|
||||
if (AE\isColEncrypted()) {
|
||||
// When AE is enabled, SQL types must be specified for sqlsrv_query
|
||||
$inputs = array("c1_int" => array(1994559593, null, null, SQLSRV_SQLTYPE_INT),
|
||||
"c2_tinyint" => array(129, null, null, SQLSRV_SQLTYPE_TINYINT),
|
||||
"c3_smallint" => array(-8455, null, null, SQLSRV_SQLTYPE_SMALLINT),
|
||||
"c4_bigint" => array(-236232445, null, null, SQLSRV_SQLTYPE_BIGINT),
|
||||
"c5_varchar" => array("ߣ*ÐO+ö+<ã:>üoîzÄ¢zz~Ãýö|vUå>|CÄUü~>buÃv<ä~Ö+.ü*ªbuî_bBC©.oîCbåîÐÖUa~/U>öAäÐBu~ozîZ/zrOOä:ß©bßo.ü©A¢höÖoßÖü>r+A/ßaªrß:ª@|bhhªª/oå<Ö:rüa+oC¢~uÄü>/.ãbOöª_b@bbߢ|uzߪ֢~uäýub©ãaZäC£ÄrÖ,üöäu+Ãîö|||,U.BråãoýbüåöÃburöoî+>öä©î,u_öb©@C:ÜåÜîÜåAÖzýbð|Z<Ãý.£rîZ|/z@¢£AýZ,ßuZ*:b.AzТä¢üßöbvbväð|<**~Uv.Ð*Ä©B*ýCUöa¢åO©Ãß*ÃÃ|ÜðA@îÃßaB<hÜîaZoöå>öüahUUA+ߣ_u|~äö.©hr£oBo<äãüO+_å<OЪÖßßväzA,~u~Obbî@ßÃãÜää©,.bO:C£Ü,äUO¢åå**hÐ~UZ©ðh<abß*üÖîC.äßh~Uð<r*ßäv£î*@¢Cv/BÖhAüB~ýAå@Z@<a_O|<©ßb*CZO,o:ã+¢£ÃZC©B¢o+>O:Z~Üoîßzb£ª£A.AÖÜÄ._O_å£ß", null, null, SQLSRV_SQLTYPE_VARCHAR(512)));
|
||||
} else {
|
||||
$inputs = array("c1_int" => 1994559593, "c2_tinyint" => 129, "c3_smallint" => -8455, "c4_bigint" => -236232445, "c5_varchar" => "ߣ*ÐO+ö+<ã:>üoîzÄ¢zz~Ãýö|vUå>|CÄUü~>buÃv<ä~Ö+.ü*ªbuî_bBC©.oîCbåîÐÖUa~/U>öAäÐBu~ozîZ/zrOOä:ß©bßo.ü©A¢höÖoßÖü>r+A/ßaªrß:ª@|bhhªª/oå<Ö:rüa+oC¢~uÄü>/.ãbOöª_b@bbߢ|uzߪ֢~uäýub©ãaZäC£ÄrÖ,üöäu+Ãîö|||,U.BråãoýbüåöÃburöoî+>öä©î,u_öb©@C:ÜåÜîÜåAÖzýbð|Z<Ãý.£rîZ|/z@¢£AýZ,ßuZ*:b.AzТä¢üßöbvbväð|<**~Uv.Ð*Ä©B*ýCUöa¢åO©Ãß*ÃÃ|ÜðA@îÃßaB<hÜîaZoöå>öüahUUA+ߣ_u|~äö.©hr£oBo<äãüO+_å<OЪÖßßväzA,~u~Obbî@ßÃãÜää©,.bO:C£Ü,äUO¢åå**hÐ~UZ©ðh<abß*üÖîC.äßh~Uð<r*ßäv£î*@¢Cv/BÖhAüB~ýAå@Z@<a_O|<©ßb*CZO,o:ã+¢£ÃZC©B¢o+>O:Z~Üoîßzb£ª£A.AÖÜÄ._O_å£ß");
|
||||
}
|
||||
$query = "SET IDENTITY_INSERT [$tableName] ON; SQL; SET IDENTITY_INSERT [$tableName] OFF;";
|
||||
$stmt = insertTest($conn, $tableName, $inputs, $query);
|
||||
print_r(sqlsrv_errors());
|
||||
unset($inputs);
|
||||
sqlsrv_free_stmt($stmt);
|
||||
|
||||
echo "Number of rows inserted: $noExpectedRows\n";
|
||||
|
@ -60,28 +123,19 @@ function ComplexQuery()
|
|||
if ($noActualRows != $noExpectedRows) {
|
||||
echo("Number of rows does not match expected value\n");
|
||||
}
|
||||
|
||||
dropTable($conn, $tableName);
|
||||
sqlsrv_close($conn);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Repro
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
function Repro()
|
||||
{
|
||||
startTest("sqlsrv_statement_complex_query");
|
||||
echo "\nTest begins...\n";
|
||||
echo "\nTest begins...\n";
|
||||
|
||||
try {
|
||||
ComplexQuery();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
echo "\nDone\n";
|
||||
endTest("sqlsrv_statement_complex_query");
|
||||
try {
|
||||
complexQuery();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
Repro();
|
||||
echo "\nDone\n";
|
||||
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
|
@ -94,4 +148,3 @@ Number of rows inserted: 2
|
|||
Number of rows fetched: 2
|
||||
|
||||
Done
|
||||
Test \"sqlsrv_statement_complex_query\" completed successfully\.
|
||||
|
|
|
@ -1,45 +1,64 @@
|
|||
--TEST--
|
||||
Test insert various data types and fetch as strings
|
||||
--SKIPIF--
|
||||
<?php require('skipif_versions_old.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
require_once('tools.inc');
|
||||
|
||||
function ExplicitFetch()
|
||||
function explicitFetch()
|
||||
{
|
||||
set_time_limit(0);
|
||||
sqlsrv_configure('WarningsReturnAsErrors', 1);
|
||||
|
||||
// Connect
|
||||
$connectionInfo = array("CharacterSet"=>"UTF-8");
|
||||
$conn = connect($connectionInfo);
|
||||
if (!$conn) {
|
||||
fatalError("Could not connect.\n");
|
||||
$conn = AE\connect($connectionInfo);
|
||||
|
||||
$tableName = 'types_explict_fetch';
|
||||
$columns = array(new AE\ColumnMeta('int', 'c1_int'),
|
||||
new AE\ColumnMeta('tinyint', 'c2_tinyint'),
|
||||
new AE\ColumnMeta('smallint', 'c3_smallint'),
|
||||
new AE\ColumnMeta('bigint', 'c4_bigint'),
|
||||
new AE\ColumnMeta('bit', 'c5_bit'),
|
||||
new AE\ColumnMeta('float', 'c6_float'),
|
||||
new AE\ColumnMeta('real', 'c7_real'),
|
||||
new AE\ColumnMeta('decimal(28,4)', 'c8_decimal'),
|
||||
new AE\ColumnMeta('numeric(32,4)', 'c9_numeric'),
|
||||
new AE\ColumnMeta('money', 'c10_money', null, true, true),
|
||||
new AE\ColumnMeta('smallmoney', 'c11_smallmoney', null, true, true),
|
||||
new AE\ColumnMeta('char(512)', 'c12_char'),
|
||||
new AE\ColumnMeta('varchar(512)', 'c13_varchar'),
|
||||
new AE\ColumnMeta('varchar(max)', 'c14_varchar_max'),
|
||||
new AE\ColumnMeta('uniqueidentifier', 'c15_uniqueidentifier'),
|
||||
new AE\ColumnMeta('datetime', 'c16_datetime'),
|
||||
new AE\ColumnMeta('smalldatetime', 'c17_smalldatetime'),
|
||||
new AE\ColumnMeta('timestamp', 'c18_timestamp')
|
||||
);
|
||||
$stmt = AE\createTable($conn, $tableName, $columns);
|
||||
if (!$stmt) {
|
||||
fatalError("Failed to create table $tableName\n");
|
||||
}
|
||||
|
||||
$tableName = GetTempTableName();
|
||||
|
||||
$stmt = sqlsrv_query($conn, "CREATE TABLE [$tableName] ([c1_int] int, [c2_tinyint] tinyint, [c3_smallint] smallint, [c4_bigint] bigint, [c5_bit] bit, [c6_float] float, [c7_real] real, [c8_decimal] decimal(28,4), [c9_numeric] numeric(32,4), [c10_money] money, [c11_smallmoney] smallmoney, [c12_char] char(512), [c13_varchar] varchar(512), [c14_varchar_max] varchar(max), [c15_uniqueidentifier] uniqueidentifier, [c16_datetime] datetime, [c17_smalldatetime] smalldatetime, [c18_timestamp] timestamp)");
|
||||
sqlsrv_free_stmt($stmt);
|
||||
|
||||
$numRows = 0;
|
||||
$data = GetInputData(++$numRows);
|
||||
$stmt = sqlsrv_query($conn, "INSERT INTO [$tableName] (c1_int, c2_tinyint, c3_smallint, c4_bigint, c5_bit, c6_float, c7_real, c8_decimal, c9_numeric, c10_money, c11_smallmoney, c12_char, c13_varchar, c14_varchar_max, c15_uniqueidentifier, c16_datetime, c17_smalldatetime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $data);
|
||||
$data = getInputData(++$numRows);
|
||||
$stmt = AE\executeQueryParams($conn, "INSERT INTO [$tableName] (c1_int, c2_tinyint, c3_smallint, c4_bigint, c5_bit, c6_float, c7_real, c8_decimal, c9_numeric, c10_money, c11_smallmoney, c12_char, c13_varchar, c14_varchar_max, c15_uniqueidentifier, c16_datetime, c17_smalldatetime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $data);
|
||||
sqlsrv_free_stmt($stmt);
|
||||
|
||||
$data = GetInputData(++$numRows);
|
||||
$stmt = sqlsrv_query($conn, "INSERT INTO [$tableName] (c1_int, c2_tinyint, c3_smallint, c4_bigint, c5_bit, c6_float, c7_real, c8_decimal, c9_numeric, c10_money, c11_smallmoney, c12_char, c13_varchar, c14_varchar_max, c15_uniqueidentifier, c16_datetime, c17_smalldatetime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $data);
|
||||
$data = getInputData(++$numRows);
|
||||
$stmt = AE\executeQueryParams($conn, "INSERT INTO [$tableName] (c1_int, c2_tinyint, c3_smallint, c4_bigint, c5_bit, c6_float, c7_real, c8_decimal, c9_numeric, c10_money, c11_smallmoney, c12_char, c13_varchar, c14_varchar_max, c15_uniqueidentifier, c16_datetime, c17_smalldatetime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $data);
|
||||
sqlsrv_free_stmt($stmt);
|
||||
|
||||
$data = GetInputData(++$numRows);
|
||||
$stmt = sqlsrv_query($conn, "INSERT INTO [$tableName] (c1_int, c2_tinyint, c3_smallint, c4_bigint, c5_bit, c6_float, c7_real, c8_decimal, c9_numeric, c10_money, c11_smallmoney, c12_char, c13_varchar, c14_varchar_max, c15_uniqueidentifier, c16_datetime, c17_smalldatetime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $data);
|
||||
$data = getInputData(++$numRows);
|
||||
$stmt = AE\executeQueryParams($conn, "INSERT INTO [$tableName] (c1_int, c2_tinyint, c3_smallint, c4_bigint, c5_bit, c6_float, c7_real, c8_decimal, c9_numeric, c10_money, c11_smallmoney, c12_char, c13_varchar, c14_varchar_max, c15_uniqueidentifier, c16_datetime, c17_smalldatetime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $data);
|
||||
sqlsrv_free_stmt($stmt);
|
||||
|
||||
$data = GetInputData(++$numRows);
|
||||
$stmt = sqlsrv_query($conn, "INSERT INTO [$tableName] (c1_int, c2_tinyint, c3_smallint, c4_bigint, c5_bit, c6_float, c7_real, c8_decimal, c9_numeric, c10_money, c11_smallmoney, c12_char, c13_varchar, c14_varchar_max, c15_uniqueidentifier, c16_datetime, c17_smalldatetime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $data);
|
||||
$data = getInputData(++$numRows);
|
||||
$stmt = AE\executeQueryParams($conn, "INSERT INTO [$tableName] (c1_int, c2_tinyint, c3_smallint, c4_bigint, c5_bit, c6_float, c7_real, c8_decimal, c9_numeric, c10_money, c11_smallmoney, c12_char, c13_varchar, c14_varchar_max, c15_uniqueidentifier, c16_datetime, c17_smalldatetime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $data);
|
||||
sqlsrv_free_stmt($stmt);
|
||||
|
||||
$stmt = sqlsrv_query($conn, "SELECT * FROM $tableName ORDER BY c18_timestamp");
|
||||
$stmt = AE\executeQuery($conn, "SELECT * FROM $tableName ORDER BY c18_timestamp");
|
||||
|
||||
$metadata = sqlsrv_field_metadata($stmt);
|
||||
$numFields = count($metadata);
|
||||
|
@ -49,10 +68,11 @@ function ExplicitFetch()
|
|||
echo "Number of Actual Rows $noActualRows is unexpected!\n";
|
||||
}
|
||||
|
||||
dropTable($conn, $tableName);
|
||||
sqlsrv_close($conn);
|
||||
}
|
||||
|
||||
function GetInputData($index)
|
||||
function getInputData($index)
|
||||
{
|
||||
switch ($index) {
|
||||
case 1:
|
||||
|
@ -68,20 +88,13 @@ function GetInputData($index)
|
|||
}
|
||||
}
|
||||
|
||||
function Repro()
|
||||
{
|
||||
startTest("sqlsrv_data_types_explict_fetch");
|
||||
echo "\nTest begins...\n";
|
||||
try {
|
||||
ExplicitFetch();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
echo "\nDone\n";
|
||||
endTest("sqlsrv_data_types_explict_fetch");
|
||||
echo "\nTest begins...\n";
|
||||
try {
|
||||
explicitFetch();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
Repro();
|
||||
echo "\nDone\n";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
|
@ -93,4 +106,3 @@ Comparing data in row 3
|
|||
Comparing data in row 4
|
||||
|
||||
Done
|
||||
Test "sqlsrv_data_types_explict_fetch" completed successfully.
|
||||
|
|
|
@ -9,11 +9,11 @@ Intentionally provide an invalid server name and set LoginTimeout. Verify the ti
|
|||
|
||||
$serverName = "WRONG_SERVER_NAME";
|
||||
|
||||
$t0 = round(microtime(true));
|
||||
$t0 = microtime(true);
|
||||
|
||||
$conn = sqlsrv_connect( $serverName , array("LoginTimeout" => 8));
|
||||
$conn = sqlsrv_connect($serverName , array("LoginTimeout" => 8));
|
||||
|
||||
$t1 = round(microtime(true));
|
||||
$t1 = microtime(true);
|
||||
|
||||
echo "Connection attempt time: " . ($t1 - $t0) . " [sec]\n";
|
||||
|
||||
|
@ -21,5 +21,5 @@ print "Done";
|
|||
?>
|
||||
|
||||
--EXPECTREGEX--
|
||||
Connection attempt time: [7-9] \[sec\]
|
||||
Connection attempt time: [7-9]\.[0-9]+ \[sec\]
|
||||
Done
|
||||
|
|
Loading…
Reference in a new issue