PageRenderTime 22ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/hphp/test/zend/bad/ext/mysql/tests/mysql_fetch_assoc.php

http://github.com/facebook/hiphop-php
PHP | 56 lines | 40 code | 15 blank | 1 comment | 6 complexity | 5a371882a1a2b0990f61d59207b60e20 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?php
  2. include "connect.inc";
  3. $tmp = NULL;
  4. $link = NULL;
  5. // Note: no SQL type tests, internally the same function gets used as for mysql_fetch_array() which does a lot of SQL type test
  6. if (!is_null($tmp = @mysql_fetch_assoc()))
  7. printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  8. if (NULL !== ($tmp = @mysql_fetch_assoc($link)))
  9. printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  10. require('table.inc');
  11. if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 1", $link)) {
  12. printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link));
  13. }
  14. print "[005]\n";
  15. var_dump(mysql_fetch_assoc($res));
  16. print "[006]\n";
  17. var_dump(mysql_fetch_assoc($res));
  18. mysql_free_result($res);
  19. if (!$res = mysql_query("SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e", $link)) {
  20. printf("[007] Cannot run query, [%d] %s\n", mysql_errno($link), $mysql_error($link));
  21. }
  22. print "[008]\n";
  23. var_dump(mysql_fetch_assoc($res));
  24. mysql_free_result($res);
  25. if (false !== ($tmp = mysql_fetch_assoc($res)))
  26. printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
  27. mysql_close($link);
  28. include('table.inc');
  29. if (!$res = mysql_query("SELECT id, label, id AS _id, CONCAT(label, 'a') _label, NULL as _foo FROM test _test ORDER BY id ASC LIMIT 1", $link)) {
  30. printf("[009] [%d] %s\n", mysql_errno($link), $mysql_error($link));
  31. }
  32. print "[010]\n";
  33. var_dump(mysql_fetch_assoc($res));
  34. mysql_free_result($res);
  35. mysql_close($link);
  36. print "done!";
  37. ?>
  38. <?php error_reporting(0); ?>
  39. <?php
  40. require_once("clean_table.inc");
  41. ?>