mirror of
https://github.com/php/php-src.git
synced 2025-08-21 01:45:16 +02:00
Merge branch 'PHP-7.1'
* PHP-7.1: Allow \PDO::setAttribute() to set pdo_dblib query timeouts
This commit is contained in:
commit
033018890d
2 changed files with 33 additions and 4 deletions
|
@ -253,14 +253,13 @@ static int dblib_set_attr(pdo_dbh_t *dbh, zend_long attr, zval *val)
|
||||||
{
|
{
|
||||||
switch(attr) {
|
switch(attr) {
|
||||||
case PDO_ATTR_TIMEOUT:
|
case PDO_ATTR_TIMEOUT:
|
||||||
return 0;
|
case PDO_DBLIB_ATTR_QUERY_TIMEOUT:
|
||||||
|
return SUCCEED == dbsettime(zval_get_long(val)) ? 1 : 0;
|
||||||
case PDO_DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER:
|
case PDO_DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER:
|
||||||
((pdo_dblib_db_handle *)dbh->driver_data)->stringify_uniqueidentifier = zval_get_long(val);
|
((pdo_dblib_db_handle *)dbh->driver_data)->stringify_uniqueidentifier = zval_get_long(val);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,32 @@ if ($stmt->execute()) {
|
||||||
echo "OK\n";
|
echo "OK\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// regular timeout attribute, set after instance created, will affect query timeout, causing this query to fail
|
||||||
|
$db = new PDO($dsn, $user, $pass);
|
||||||
|
$db->setAttribute(PDO::ATTR_TIMEOUT, 1);
|
||||||
|
$stmt = $db->prepare($sql);
|
||||||
|
if (!$stmt->execute()) {
|
||||||
|
echo "OK\n";
|
||||||
|
|
||||||
|
// expect some kind of error code
|
||||||
|
if ($stmt->errorCode() != '00000') {
|
||||||
|
echo "OK\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// pdo_dblib-specific timeout attribute, set after instance created, will control query timeout, causing this query to fail
|
||||||
|
$db = new PDO($dsn, $user, $pass);
|
||||||
|
$db->setAttribute(PDO::DBLIB_ATTR_QUERY_TIMEOUT, 1);
|
||||||
|
$stmt = $db->prepare($sql);
|
||||||
|
if (!$stmt->execute()) {
|
||||||
|
echo "OK\n";
|
||||||
|
|
||||||
|
// expect some kind of error code
|
||||||
|
if ($stmt->errorCode() != '00000') {
|
||||||
|
echo "OK\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// regular timeout attribute will affect query timeout, causing this query to fail
|
// regular timeout attribute will affect query timeout, causing this query to fail
|
||||||
$db = new PDO($dsn, $user, $pass, [PDO::ATTR_TIMEOUT => 1]);
|
$db = new PDO($dsn, $user, $pass, [PDO::ATTR_TIMEOUT => 1]);
|
||||||
$stmt = $db->prepare($sql);
|
$stmt = $db->prepare($sql);
|
||||||
|
@ -49,3 +75,7 @@ OK
|
||||||
OK
|
OK
|
||||||
OK
|
OK
|
||||||
OK
|
OK
|
||||||
|
OK
|
||||||
|
OK
|
||||||
|
OK
|
||||||
|
OK
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue