public
Description: A simple Nu/Objective-C interface to MySQL databases.
Homepage: http://programming.nu
Clone URL: git://github.com/timburks/numysql.git
New convenience methods for queries.

Three new methods of MySQLConnection allow query
results to be returned as arrays, dictionaries,
or individual values. In all three cases, each
row is returned as a dictionary.
timburks (author)
Wed Apr 30 09:42:10 -0700 2008
commit  a71bcf47dd2a8b2c930f50ac838a60edc47b06f1
tree    a989de1a1ad0a51852a6fe09e74b7c408d2b63fc
parent  2681c9bd3c64f70029bb6da19c19288161bbcc98
...
2
3
4
5
6
 
 
7
8
9
...
19
20
21
22
 
23
24
25
...
2
3
4
 
 
5
6
7
8
9
...
19
20
21
 
22
23
24
25
0
@@ -2,8 +2,8 @@
0
 (set @m_files (filelist "^objc/.*.m$"))
0
 (set @nu_files    (filelist "^nu/.*nu$"))
0
 
0
-;; (set mysql_cflags ((NSString stringWithShellCommand:"mysql_config --cflags") chomp))
0
-(set mysql_cflags "-I/usr/local/mysql/include -arch i386 -fno-common")
0
+(set mysql_cflags ((NSString stringWithShellCommand:"mysql_config --cflags") chomp))
0
+;;(set mysql_cflags "-I/usr/local/mysql/include -arch i386 -fno-common")
0
 (set mysql_libs ((NSString stringWithShellCommand:"mysql_config --libs") chomp))
0
 
0
 (set SYSTEM ((NSString stringWithShellCommand:"uname") chomp))
0
@@ -19,7 +19,7 @@
0
 
0
 ;; framework description
0
 (set @framework "NuMySQL")
0
-(set @framework_identifier "nu.programming.numysql")
0
+(set @framework_identifier "nu.programming.mysql")
0
 (set @framework_creator_code "????")
0
 
0
 (compilation-tasks)
...
16
17
18
 
19
20
21
...
120
121
122
 
 
 
 
 
 
 
 
 
123
124
125
...
16
17
18
19
20
21
22
...
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
0
@@ -16,6 +16,7 @@ See the License for the specific language governing permissions and
0
 limitations under the License.
0
 */
0
 #import <Foundation/Foundation.h>
0
+#import <Nu/Nu.h>
0
 #import "mysql.h"
0
 
0
 @interface MySQLField : NSObject
0
@@ -120,6 +121,15 @@ limitations under the License.
0
 
0
 @implementation MySQLConnection
0
 
0
++ (void) load
0
+{
0
+ static int initialized = 0;
0
+ if (!initialized) {
0
+ initialized = 1;
0
+ [Nu loadNuFile:@"mysql" fromBundleWithIdentifier:@"nu.programming.mysql" withContext:nil];
0
+ }
0
+}
0
+
0
 - (id) init
0
 {
0
     [super init];
...
49
50
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
...
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
0
@@ -49,4 +49,25 @@ END))
0
         (assert_equal 1 (result rowCount))
0
         (set row (result nextRowAsArray))
0
         (assert_equal "bart" (row objectAtIndex:0))
0
+
0
+ (set result (m queryAsValue:"select * from triples where subject = 'homer' and relation = 'wife'"))
0
+ (assert_equal "marge" (result "object"))
0
+
0
+ (set result (m queryAsDictionary:"select * from triples where subject = 'homer'" withKey:"relation"))
0
+ (assert_equal "lisa" ((result "daughter") "object"))
0
+
0
+ (set result (m queryAsArray:"select * from triples"))
0
+ (assert_equal 12 (result count))
0
+
0
+ ;; some empty queries
0
+
0
+ (set result (m queryAsValue:"select * from triples where subject = 'homer' and relation = 'husband'"))
0
+ (assert_equal nil result)
0
+
0
+ (set result (m queryAsDictionary:"select * from triples where subject = 'homer' and relation = 'husband'" withKey:"relation"))
0
+ (assert_equal 0 (result count))
0
+
0
+ (set result (m queryAsArray:"select * from triples where subject = 'homer' and relation = 'husband'"))
0
+ (assert_equal 0 (result count))
0
+
0
         (set result (m query:"drop database NuMySQLTest"))))

Comments

    No one has commented yet.