B2G/gecko/toolkit/components/places/tests/head_common.js
/**
 * Dumps the rows of a table out to the console.
 *
 * @param aName
 *        The name of the table or view to output.
 */
Dumps the rows of a table out to the console.
@param aName
The name of the table or view to output.
Dumps the rows of a table out to the console . @param aName The name of the table or view to output .
function dump_table(aName)
{
  let stmt = DBConn().createStatement("SELECT * FROM " + aName);
  print("\n*** Printing data from " + aName);
  let count = 0;
  while (stmt.executeStep()) {
    let columns = stmt.numEntries;
    if (count == 0) {
      for (let i = 0; i < columns; i++)
        dump(stmt.getColumnName(i) + "\t");
      dump("\n");
    }
    for (let i = 0; i < columns; i++) {
      switch (stmt.getTypeOfIndex(i)) {
        case Ci.mozIStorageValueArray.VALUE_TYPE_NULL:
          dump("NULL\t");
          break;
        case Ci.mozIStorageValueArray.VALUE_TYPE_INTEGER:
          dump(stmt.getInt64(i) + "\t");
          break;
        case Ci.mozIStorageValueArray.VALUE_TYPE_FLOAT:
          dump(stmt.getDouble(i) + "\t");
          break;
        case Ci.mozIStorageValueArray.VALUE_TYPE_TEXT:
          dump(stmt.getString(i) + "\t");
          break;
      }
    }
    dump("\n");
    count++;
  }
  print("*** There were a total of " + count + " rows of data.\n");
  stmt.finalize();
}
function dump_table ( aName ) { let stmt = DBConn ( ) . createStatement ( "SELECT * FROM " + aName ) ; print ( "\n*** Printing data from " + aName ) ; let count = 0 ; while ( stmt . executeStep ( ) ) { let columns = stmt . numEntries ; if ( count == 0 ) { for ( let i = 0 ; i < columns ; i ++ ) dump ( stmt . getColumnName ( i ) + "\t" ) ; dump ( "\n" ) ; } for ( let i = 0 ; i < columns ; i ++ ) { switch ( stmt . getTypeOfIndex ( i ) ) { case Ci . mozIStorageValueArray . VALUE_TYPE_NULL : dump ( "NULL\t" ) ; break ; case Ci . mozIStorageValueArray . VALUE_TYPE_INTEGER : dump ( stmt . getInt64 ( i ) + "\t" ) ; break ; case Ci . mozIStorageValueArray . VALUE_TYPE_FLOAT : dump ( stmt . getDouble ( i ) + "\t" ) ; break ; case Ci . mozIStorageValueArray . VALUE_TYPE_TEXT : dump ( stmt . getString ( i ) + "\t" ) ; break ; } } dump ( "\n" ) ; count ++ ; } print ( "*** There were a total of " + count + " rows of data.\n" ) ; stmt . finalize ( ) ; }
Dumps the rows of a table out to the console.
Dumps the rows of a table out to the console .
// Print the column names. // Print the rows.