sqlite3_11_numrows.phpt 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. SQLite3::prepare number of rows
  3. --EXTENSIONS--
  4. sqlite3
  5. --SKIPIF--
  6. <?php
  7. // Create an instance of the ReflectionMethod class
  8. try {
  9. $method = new ReflectionMethod('sqlite3result', 'numRows');
  10. } catch (ReflectionException $e) {
  11. die("skip SQLite3Result::numRows method does not exist");
  12. }
  13. ?>
  14. --FILE--
  15. <?php
  16. require_once(__DIR__ . '/new_db.inc');
  17. define('TIMENOW', time());
  18. echo "Creating Table\n";
  19. var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)'));
  20. echo "INSERT into table\n";
  21. var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')"));
  22. var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')"));
  23. echo "SELECTING results\n";
  24. $results = $db->query("SELECT * FROM test ORDER BY id ASC");
  25. echo "Number of rows\n";
  26. var_dump($results->numRows());
  27. $results->finalize();
  28. echo "Closing database\n";
  29. var_dump($db->close());
  30. echo "Done\n";
  31. ?>
  32. --EXPECT--
  33. Creating Table
  34. bool(true)
  35. INSERT into table
  36. bool(true)
  37. bool(true)
  38. SELECTING results
  39. Number of rows
  40. int(2)
  41. Closing database
  42. bool(true)
  43. Done