mysql_db_query.phpt 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. --TEST--
  2. mysql_db_query()
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifconnectfailure.inc');
  7. ?>
  8. --FILE--
  9. <?php
  10. include "connect.inc";
  11. // NOTE: this function is deprecated. We do only the most necessary
  12. // to test it. We don't test all aspects of the documented behaviour.
  13. $tmp = NULL;
  14. $link = NULL;
  15. if (NULL !== ($tmp = @mysql_db_query()))
  16. printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
  17. if (NULL !== ($tmp = @mysql_db_query($link)))
  18. printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
  19. if (NULL !== ($tmp = @mysql_db_query($link)))
  20. printf("[003] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
  21. require('table.inc');
  22. if (!$res = @mysql_db_query($db, 'SELECT id, label FROM test ORDER BY id LIMIT 1', $link))
  23. printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link));
  24. $row = mysql_fetch_assoc($res);
  25. if (1 != $row['id'])
  26. printf("[005] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']);
  27. if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($row['label'])) {
  28. printf("[006] No unicode returned! [%d] %s\n", mysql_errno($link), mysql_error($link));
  29. var_inspect($row);
  30. }
  31. mysql_free_result($res);
  32. if (!$res = @mysql_db_query($db, 'SELECT id, label FROM test ORDER BY id LIMIT 1'))
  33. printf("[007] [%d] %s\n", mysql_errno(), mysql_error());
  34. $row = mysql_fetch_assoc($res);
  35. if (1 != $row['id'])
  36. printf("[008] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']);
  37. if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($row['label'])) {
  38. printf("[009] No unicode returned! [%d] %s\n", mysql_errno(), mysql_error());
  39. var_inspect($row);
  40. }
  41. mysql_free_result($res);
  42. mysql_close($link);
  43. print "done!\n";
  44. ?>
  45. --CLEAN--
  46. <?php
  47. require_once("clean_table.inc");
  48. ?>
  49. --EXPECTF--
  50. Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
  51. done!