Check-in [2b4b2a5091]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:2b4b2a5091dc81ae770c47f915210d4be3275710
Date: 2012-07-22 11:39:04
User: stephan
Comment:minor th1 doc and script code cleanups.
Tags And Properties
Changes

Changes to test/th1-query-api-1.th1

17 set i 0 17 set i 0 18 set colNames(0) 0 18 set colNames(0) 0 19 for {set i 0} {$i < $colCount} {incr i} { 19 for {set i 0} {$i < $colCount} {incr i} { 20 set colNames($i) [query $stmt col name $i] 20 set colNames($i) [query $stmt col name $i] 21 puts "colNames($i)=" $colNames($i) "\n" 21 puts "colNames($i)=" $colNames($i) "\n" 22 } 22 } 23 23 24 for {set row 0} {0 < [query $stmt step]} {incr row} { | 24 for {set row 0} {[query $stmt step]} {incr row} { 25 for {set i 0} {$i < $colCount} {incr i} { 25 for {set i 0} {$i < $colCount} {incr i} { 26 if {$i > 0} { 26 if {$i > 0} { 27 puts $sep 27 puts $sep 28 } else { 28 } else { 29 puts "#$row: $sep" 29 puts "#$row: $sep" 30 } 30 } 31 puts $colNames($i) = [query $stmt col string $i] 31 puts $colNames($i) = [query $stmt col string $i] ................................................................................................................................................................................ 41 proc query_step_each {{stmt} {callback}} { 41 proc query_step_each {{stmt} {callback}} { 42 set colNames(0) 0 42 set colNames(0) 0 43 set colCount [query $stmt col count] 43 set colCount [query $stmt col count] 44 for {set i 0} {$i < $colCount} {incr i} { 44 for {set i 0} {$i < $colCount} {incr i} { 45 set colNames($i) [query $stmt col name $i] 45 set colNames($i) [query $stmt col name $i] 46 } 46 } 47 upvar cb $callback 47 upvar cb $callback 48 for {set row 0} {0 < [query $stmt step]} {incr row} { | 48 for {set row 0} {[query $stmt step]} {incr row} { 49 #puts "Calling callback: $stmt $colCount colNames\n" 49 #puts "Calling callback: $stmt $colCount colNames\n" 50 $callback $stmt $colCount 50 $callback $stmt $colCount 51 } 51 } 52 } 52 } 53 53 54 set sql {SELECT uid, login FROM user WHERE uid!=?} 54 set sql {SELECT uid, login FROM user WHERE uid!=?} 55 #set sql {SELECT uid, login FROM user WHERE login=?} 55 #set sql {SELECT uid, login FROM user WHERE login=?}

Changes to test/th1-query-api-2.th1

4 SELECT login, cap, cexpire, mtime, NULL FROM user 4 SELECT login, cap, cexpire, mtime, NULL FROM user 5 WHERE uid<? AND cexpire IS NOT NULL 5 WHERE uid<? AND cexpire IS NOT NULL 6 AND mtime IS NOT NULL 6 AND mtime IS NOT NULL 7 }] 7 }] 8 puts "stmt ID=$stmt\n" 8 puts "stmt ID=$stmt\n" 9 # query bind int $stmt 1 2 9 # query bind int $stmt 1 2 10 # query $stmt bind int 1 2 10 # query $stmt bind int 1 2 11 query $stmt bind 1 int 2 | 11 query $stmt bind 1 int 5 12 # segfault: query bind 1 int $stmt 2 12 # segfault: query bind 1 int $stmt 2 13 set sep "\n" 13 set sep "\n" 14 for {} {0 < [query $stmt step]} {} { | 14 for {} {[query $stmt step]} {} { 15 puts [query $stmt col string 0] $sep 15 puts [query $stmt col string 0] $sep 16 puts [query $stmt col time 2 {%Y%m%d @ %H:%M:%S}] $sep 16 puts [query $stmt col time 2 {%Y%m%d @ %H:%M:%S}] $sep 17 puts [query $stmt col time 2 {%Y%m%d @ %H:%M:%S} {+10 years}] $sep 17 puts [query $stmt col time 2 {%Y%m%d @ %H:%M:%S} {+10 years}] $sep 18 puts [query $stmt col 2 time {%Y%m%d @ %H:%M:%S} {+10 years}] $sep 18 puts [query $stmt col 2 time {%Y%m%d @ %H:%M:%S} {+10 years}] $sep 19 # puts [query col time $stmt 2 %s] $sep 19 # puts [query col time $stmt 2 %s] $sep 20 puts [query col time $stmt 3 %s unixepoch] $sep 20 puts [query col time $stmt 3 %s unixepoch] $sep 21 # puts [query strftime %s [query col string $stmt 3] unixepoch] 21 # puts [query strftime %s [query col string $stmt 3] unixepoch]

Changes to www/th1_query.wiki

6 Example usage: 6 Example usage: 7 7 8 <nowiki><pre> 8 <nowiki><pre> 9 &lt;th1> 9 &lt;th1> 10 catch { 10 catch { 11 set stmt [query prepare "SELECT login, cap FROM user"] 11 set stmt [query prepare "SELECT login, cap FROM user"] 12 puts "stmt ID=$stmt\n" 12 puts "stmt ID=$stmt\n" 13 for {} {0 < [query $stmt step]} {} { | 13 for {} {[query $stmt step]} {} { 14 puts [query $stmt col string 0] ": " [query $stmt col string 1] "\n" | 14 puts [query $stmt col string 0] " " [query $stmt col string 1] \n 15 } 15 } 16 query $stmt finalize 16 query $stmt finalize 17 return 0 17 return 0 18 } rc 18 } rc 19 if {0 != $rc} { 19 if {0 != $rc} { 20 puts "ERROR: $rc\n" 20 puts "ERROR: $rc\n" 21 } 21 }