bug54929.phpt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. --TEST--
  2. Bug #54929 (Parse error with single quote in sql comment (pdo-mysql))
  3. --EXTENSIONS--
  4. pdo_mysql
  5. --SKIPIF--
  6. <?php
  7. require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
  8. MySQLPDOTest::skip();
  9. ?>
  10. --FILE--
  11. <?php
  12. require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
  13. $pdodb = PDOTest::test_factory(__DIR__ . '/common.phpt');
  14. function testQuery($query) {
  15. global $pdodb;
  16. $stmt = $pdodb->prepare($query);
  17. if (!$stmt->execute(array("foo"))) {
  18. var_dump($stmt->errorInfo());
  19. } else{
  20. var_dump($stmt->fetch(PDO::FETCH_ASSOC));
  21. }
  22. }
  23. testQuery("/* ' */ select ? as f1 /* ' */");
  24. testQuery("/* '-- */ select ? as f1 /* *' */");
  25. testQuery("/* ' */ select ? as f1 --';");
  26. testQuery("/* ' */ select ? as f1 -- 'a;");
  27. testQuery("/*'**/ select ? as f1 /* ' */");
  28. testQuery("/*'***/ select ? as f1 /* ' */");
  29. testQuery("/*'**a ***b / ****
  30. ******
  31. **/ select ? as f1 /* ' */");
  32. ?>
  33. --EXPECTF--
  34. array(1) {
  35. ["f1"]=>
  36. string(3) "foo"
  37. }
  38. array(1) {
  39. ["f1"]=>
  40. string(3) "foo"
  41. }
  42. Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near '--'' at line 1 in %s on line %d
  43. array(3) {
  44. [0]=>
  45. string(5) "42000"
  46. [1]=>
  47. int(1064)
  48. [2]=>
  49. string(%d) "You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near '--'' at line 1"
  50. }
  51. array(1) {
  52. ["f1"]=>
  53. string(3) "foo"
  54. }
  55. array(1) {
  56. ["f1"]=>
  57. string(3) "foo"
  58. }
  59. array(1) {
  60. ["f1"]=>
  61. string(3) "foo"
  62. }
  63. array(1) {
  64. ["f1"]=>
  65. string(3) "foo"
  66. }