PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-php
PHP | 50 lines | 40 code | 10 blank | 0 comment | 8 complexity | f20d5271811a8d4504eda3d24293b7a0 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_once('connect.inc');
  3. class class24 {
  4. function __construct() {
  5. echo __METHOD__ . "\n";
  6. }
  7. }
  8. $data = array("one", "two", "three");
  9. if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
  10. printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  11. $host, $user, $db, $port, $socket);
  12. if (!mysql_query('DROP TABLE IF EXISTS test', $link))
  13. printf("[002] [%d] %s\n", mysql_errno($link), mysql_error($link));
  14. if (!mysql_query("CREATE TABLE test(a varchar(10))", $link))
  15. printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
  16. foreach ($data as $str) {
  17. if (!mysql_query(sprintf("INSERT INTO test VALUES('%s')", $str), $link))
  18. printf("[004 - %s] [%d] %s\n", $str, mysql_errno($link), mysql_error($link));
  19. }
  20. echo "==stdClass==\n";
  21. if (!$res = mysql_query("SELECT a FROM test", $link))
  22. printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));
  23. while ($obj = mysql_fetch_object($res)) {
  24. var_dump($obj);
  25. }
  26. mysql_free_result($res);
  27. echo "==class24==\n";
  28. if (!$res = mysql_query("SELECT a FROM test", $link))
  29. printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
  30. while ($obj = mysql_fetch_object($res, 'class24')) {
  31. var_dump($obj);
  32. }
  33. mysql_free_result($res);
  34. mysql_close($link);
  35. print "done!";
  36. ?>
  37. <?php error_reporting(0); ?>
  38. <?php
  39. require_once("clean_table.inc");
  40. ?>