bug54929.phpt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. --TEST--
  2. Bug #54929 (Parse error with single quote in sql comment (pdo-mysql))
  3. --SKIPIF--
  4. <?php
  5. require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
  6. require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
  7. MySQLPDOTest::skip();
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
  12. $pdodb = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
  13. function testQuery($query) {
  14. global $pdodb;
  15. $stmt = $pdodb->prepare($query);
  16. if (!$stmt->execute(array("foo"))) {
  17. var_dump($stmt->errorInfo());
  18. } else{
  19. var_dump($stmt->fetch(PDO::FETCH_ASSOC));
  20. }
  21. }
  22. testQuery("/* ' */ select ? as f1 /* ' */");
  23. testQuery("/* '-- */ select ? as f1 /* *' */");
  24. testQuery("/* ' */ select ? as f1 --';");
  25. testQuery("/* ' */ select ? as f1 -- 'a;");
  26. testQuery("/*'**/ select ? as f1 /* ' */");
  27. testQuery("/*'***/ select ? as f1 /* ' */");
  28. testQuery("/*'**a ***b / ****
  29. ******
  30. **/ select ? as f1 /* ' */");
  31. ?>
  32. --EXPECTF--
  33. array(1) {
  34. ["f1"]=>
  35. string(3) "foo"
  36. }
  37. array(1) {
  38. ["f1"]=>
  39. string(3) "foo"
  40. }
  41. 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
  42. array(3) {
  43. [0]=>
  44. string(5) "42000"
  45. [1]=>
  46. int(1064)
  47. [2]=>
  48. 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"
  49. }
  50. array(1) {
  51. ["f1"]=>
  52. string(3) "foo"
  53. }
  54. array(1) {
  55. ["f1"]=>
  56. string(3) "foo"
  57. }
  58. array(1) {
  59. ["f1"]=>
  60. string(3) "foo"
  61. }
  62. array(1) {
  63. ["f1"]=>
  64. string(3) "foo"
  65. }