test-mysql.nut 919 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. local db = MySQL("localhost", "tribiqtrunk", "password", "tribiqtrunk");
  2. print(db.version());
  3. print(db.exec_scalar("select count(*) from tribiq_content;"));
  4. local qry = db.exec_query("select * from tribiq_content;");
  5. local col_count = qry.col_count();
  6. while(qry.next_row()){
  7. for(local i=0; i < col_count; ++i){
  8. print1(qry.col_value(i));
  9. print1("|");
  10. }
  11. print1("\n");
  12. }
  13. print("row_as_array");
  14. qry._curr_row = -1;
  15. while(qry.next_row()){
  16. foreach(v in qry.row_as_array()){
  17. print1(v);
  18. print1("|");
  19. }
  20. print1("\n");
  21. }
  22. local stmt = db.prepare("select * from tribiq_content;");
  23. qry = stmt.execute();
  24. col_count = qry.col_count();
  25. while(qry.next_row()){
  26. for(local i=0; i < col_count; ++i){
  27. print1(qry.col_value(i));
  28. print1("|");
  29. }
  30. print1("\n");
  31. }
  32. print("row_as_array");
  33. qry._curr_row = -1;
  34. while(qry.next_row()){
  35. foreach(v in qry.row_as_array()){
  36. print1(v);
  37. print1("|");
  38. }
  39. print1("\n");
  40. }
  41. db.close();