Initial import.
FossilOrigin-Name: de46b0e10c5d9f516acbbf2ea01d84d0d5ac126412949d459265279262a1b87e
This commit is contained in:
commit
dbfce3528e
15 changed files with 586 additions and 0 deletions
44
test.m
Normal file
44
test.m
Normal file
|
@ -0,0 +1,44 @@
|
|||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
#import "PGConnection.h"
|
||||
#import "PGConnectionFailedException.h"
|
||||
|
||||
@interface Test: OFObject
|
||||
{
|
||||
PGConnection *connection;
|
||||
}
|
||||
@end
|
||||
|
||||
OF_APPLICATION_DELEGATE(Test)
|
||||
|
||||
@implementation Test
|
||||
- (void)applicationDidFinishLaunching
|
||||
{
|
||||
PGResult *result;
|
||||
|
||||
connection = [[PGConnection alloc] init];
|
||||
[connection setParameters:
|
||||
[OFDictionary dictionaryWithKeysAndObjects: @"user", @"js",
|
||||
@"dbname", @"js", nil]];
|
||||
[connection connect];
|
||||
|
||||
[connection executeCommand: @"DROP TABLE IF EXISTS test"];
|
||||
[connection executeCommand: @"CREATE TABLE test ("
|
||||
@" id integer,"
|
||||
@" name varchar(255),"
|
||||
@" content text"
|
||||
@")"];
|
||||
[connection executeCommand: @"INSERT INTO test (id, name, content) "
|
||||
@"VALUES($1, $2, $3)"
|
||||
parameters: @[@"1", @"foo", @"Hallo Welt!"]];
|
||||
[connection executeCommand: @"INSERT INTO test (id, name, content) "
|
||||
@"VALUES($1, $2, $3)"
|
||||
parameters: @[@"2", @"bla", @"Blup!!"]];
|
||||
|
||||
result = [connection executeCommand: @"SELECT * FROM test"];
|
||||
of_log(@"%@", result);
|
||||
of_log(@"JSON: %@", [result JSONRepresentation]);
|
||||
|
||||
[OFApplication terminate];
|
||||
}
|
||||
@end
|
Loading…
Add table
Add a link
Reference in a new issue