Diff
Not logged in

Differences From:

File src/db.c part of check-in [916b6e4b3b] - Improvements to web-based user management. by drh on 2007-07-21 19:32:06. [view]

To:

File src/db.c part of check-in [3dcaed8d86] - When accessing a remote repository, if there is a username/password specified as part of the URI, use these to login. by dan on 2007-07-28 07:09:25. [view]

@@ -763,8 +763,39 @@
 }
 void db_lset_int(const char *zName, int value){
   db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value);
 }
+
+int db_row_to_table(const char *zFormat, ...){
+  Stmt q;
+  va_list ap;
+  int rc;
+
+  va_start(ap, zFormat);
+  rc = db_vprepare(&q, zFormat, ap);
+  va_end(ap);
+  if( rc!=SQLITE_OK ){
+    return rc;
+  }
+
+  @ <table border="0" cellpadding="0" cellspacing="0">
+  if( db_step(&q)==SQLITE_ROW ){
+    int ii;
+    for(ii=0; ii<sqlite3_column_count(q.pStmt); ii++){
+      char *zCol = htmlize(sqlite3_column_name(q.pStmt, ii), -1);
+      char *zVal = htmlize(sqlite3_column_text(q.pStmt, ii), -1);
+
+      @ <tr><td align=right>%s(zCol):<td width=10><td>%s(zVal)
+
+      free(zVal);
+      free(zCol);
+    }
+  }
+  @ </table>
+
+  return db_finalize(&q);
+}
+
 
 /*
 ** COMMAND: open
 **