config.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. // bug #72969 reflects a bug with FreeTDS, not with pdo_dblib
  3. // this function will version detect so the relevant tests can XFAILIF
  4. function driver_supports_batch_statements_without_select($db) {
  5. $version = $db->getAttribute(PDO::DBLIB_ATTR_VERSION);
  6. // assume driver doesn't have this bug if not using FreeTDS
  7. if (!strstartswith($version, 'freetds ')) {
  8. return true;
  9. }
  10. // hasn't made it to numbered release yet
  11. if (!strstartswith($version, 'freetds v1.1.dev.')) {
  12. return false;
  13. }
  14. // fc820490336c50d5c175d2a15327383256add4c9 was committed on the 5th
  15. return intval(substr($version, -8)) >= 20161206;
  16. }
  17. function strstartswith($haystack, $needle) {
  18. return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false;
  19. }
  20. if (false !== getenv('PDO_DBLIB_TEST_DSN')) {
  21. $dsn = getenv('PDO_DBLIB_TEST_DSN');
  22. } else {
  23. $dsn = 'dblib:host=localhost;dbname=test';
  24. }
  25. if (false !== getenv('PDO_DBLIB_TEST_USER')) {
  26. $user = getenv('PDO_DBLIB_TEST_USER');
  27. } else {
  28. $user = 'php';
  29. }
  30. if (false !== getenv('PDO_DBLIB_TEST_PASS')) {
  31. $pass = getenv('PDO_DBLIB_TEST_PASS');
  32. } else {
  33. $pass = 'password';
  34. }
  35. try {
  36. $db = new PDO($dsn, $user, $pass);
  37. $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  38. $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
  39. } catch (PDOException $e) {
  40. die('skip ' . $e->getMessage());
  41. }
  42. ?>