public
Description: A simple Nu/Objective-C interface to PostgreSQL databases.
Homepage: http://programming.nu
Clone URL: git://github.com/timburks/nupostgresql.git
minor refactoring.
timburks (author)
Thu Jul 31 16:47:18 -0700 2008
commit  d287cbd4a1ac4d670532948e1459382b5380888e
tree    1d133bde49f8803139dd9f5b802b96219478d81c
parent  fcba024e040bd1d69700c5216dd49a8329e38348
...
25
26
27
 
 
 
 
 
 
 
 
 
 
 
 
 
28
29
30
...
35
36
37
 
38
39
40
41
42
43
44
45
46
47
48
49
 
 
 
 
 
 
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 
 
 
 
 
 
64
65
66
67
68
69
70
 
 
 
 
 
...
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
...
48
49
50
51
52
53
54
55
 
 
 
 
 
 
 
 
56
57
58
59
60
61
62
63
64
65
66
 
 
 
 
 
 
 
 
 
67
68
69
70
71
72
73
74
75
76
 
 
 
77
78
79
80
81
0
@@ -25,6 +25,19 @@
0
              (a addObject: (self dictionaryForTuple:i))))
0
         a)
0
      
0
+ (- (id) dictionaryWithKey:(id) key is
0
+ (set d (dict))
0
+ ((self tupleCount) times:
0
+ (do (i)
0
+ (set row (self dictionaryForTuple:i))
0
+ (d setValue:row forKey:(row valueForKey:key))))
0
+ d)
0
+
0
+ (- (id) value is
0
+ (if (eq (self tupleCount) 1)
0
+ (then (self dictionaryForTuple:0))
0
+ (else nil)))
0
+
0
      (- (id) dictionaryForTuple:(int)i is
0
         (set d (dict))
0
         ((self fieldTypes) eachWithIndex:
0
@@ -35,36 +48,34 @@
0
         d))
0
 
0
 (class PGConnection (ivar-accessors)
0
+
0
      ;; Perform a query and return the result as an array of dictionaries.
0
      ;; Each row of a query result is returned as a dictionary.
0
      (- (id) queryAsArray:(id) query is
0
         (set result (self query:query))
0
- (if result
0
- (then (set a (array))
0
- ((result tupleCount) times:
0
- (do (i)
0
- (a addObject: (result dictionaryForTuple:i))))
0
- a)
0
- (else nil)))
0
-
0
+ (result array))
0
+
0
+ (- (id) queryAsArray:(id) query withArguments:(id) args is
0
+ (set result (self query:query withArguments:args))
0
+ (result array))
0
+
0
      ;; Perform a query and return the result as a dictionary of dictionaries,
0
      ;; with the top-level dictionary keyed by the specified key.
0
      ;; Each row of a query result is returned as a dictionary.
0
      (- (id) queryAsDictionary:(id) query withKey:(id) key is
0
         (set result (self query:query))
0
- (if result
0
- (then (set d (dict))
0
- ((result tupleCount) times:
0
- (do (i)
0
- (set row (result dictionaryForTuple:i))
0
- (d setValue:row forKey:(row valueForKey:key))))
0
- d)
0
- (else nil)))
0
-
0
+ (result dictionaryWithKey:key))
0
+
0
+ (- (id) queryAsDictionary:(id) query withArguments:(id) args withKey:(id) key is
0
+ (set result (self query:query withArguments:args))
0
+ (result dictionaryWithKey:key))
0
+
0
      ;; Perform a query and return a single result as a dictionary.
0
      ;; Returns nil if multiple matches exist.
0
      (- (id) queryAsValue:(id) query is
0
         (set result (self query:query))
0
- (if (eq (result tupleCount) 1)
0
- (then (result dictionaryForTuple:0))
0
- (else nil))))
0
+ (result value))
0
+
0
+ (- (id) queryAsValue:(id) query withArguments:(id) args is
0
+ (set result (self query:query withArguments:args))
0
+ (result value)))

Comments

    No one has commented yet.