PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/yadal/test/test.php

https://github.com/reshadf/Library
PHP | 57 lines | 40 code | 11 blank | 6 comment | 5 complexity | 9dd251c3591afad0ec7aef32ecdd27da MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /**
  3. * General test file which is used for every db layer to test it
  4. *
  5. * @package Yadal
  6. */
  7. //
  8. if( is_object( $db ) && method_exists( $db, 'getTables') )
  9. {
  10. echo "Tables:\n";
  11. print_var( $db -> getTables() );
  12. }
  13. echo "Fetch fieldnames:\n";
  14. print_r( $db -> getFieldNames( $table ) );
  15. echo "Field types in table ".$table.":\n";
  16. print_var( $db-> getFieldTypes( $table ) );
  17. echo "\nGet primary key(s):\n";
  18. print_r( $db -> getPrKeys( $table ) );
  19. echo "\nGet not null fields:\n";
  20. print_r( $db -> getNotNullFields( $table ) );
  21. echo "\nGet fields which should be unique:\n";
  22. print_r( $db -> getUniqueFields( $table ) );
  23. echo "\nRun a query:\n";
  24. $sql = $db -> query ( "SELECT * FROM ".$db->quote($table) );
  25. print_r ( $sql );
  26. echo "\n\nRecords count:\n";
  27. echo $db -> recordCount($sql);
  28. echo "\n\nGet record:\n<table border='1' cellspacing='0' cellpadding='2'>\n";
  29. $first = true;
  30. while( $row = $db -> getRecord($sql) ) {
  31. echo "<tr>\n";
  32. foreach( $row as $field => $value ) {
  33. if( $first ) {
  34. echo "<td valign='top' nowrap>$field<hr size='3' color='black'>$value</td>\n";
  35. } else {
  36. echo "<td nowrap>$value</td>\n";
  37. }
  38. }
  39. if( $first ) $first = false;
  40. echo "</tr>\n";
  41. flush();
  42. }
  43. echo "</table>\n";
  44. echo "\n\nClose the connection:\n";
  45. print_r( $db -> close() );
  46. ?>