DatabaseKit  0.5
DBConnection Class Reference

#import <DBConnection.h>

Inheritance diagram for DBConnection:
[legend]
Collaboration diagram for DBConnection:
[legend]

Instance Methods

(instancetype) - initWithURL:error:
 
(DBResult *) - execute:substitutions:error:
 
(BOOL) - executeUpdate:substitutions:error:
 
(BOOL) - closeConnection:
 
(NSArray *) - tableNames
 
(BOOL) - tableExists:
 
(NSDictionary *) - columnsForTable:
 
(BOOL) - transaction:
 
(BOOL) - beginTransaction:
 
(BOOL) - rollBack:
 
(BOOL) - endTransaction:
 
(BOOL) - executeWriteQueriesInTransaction:error:
 

Class Methods

(void) + registerConnectionClass:
 
(BOOL) + canHandleURL:
 
(id) + openConnectionWithURL:error:
 
(NSString *) + sqlForType:
 
(DBType) + typeForSql:
 
(DBType) + typeForObjCScalarEncoding:
 
(DBType) + typeForClass:
 

Protected Attributes

NSURL * _URL
 

Properties

NSURL * URL
 

Detailed Description

Definition at line 41 of file DBConnection.h.

Method Documentation

- (BOOL) beginTransaction: (NSError **)  outErr

Begins a transaction (in most cases, using -transaction: is preferred)

Definition at line 78 of file DBConnection.m.

+ (BOOL) canHandleURL: (NSURL *)  URL

Indicates whether or not the class can handle a URL or not

Definition at line 13 of file DBConnection.m.

- (BOOL) closeConnection: (NSError **)  outErr

Closes the connection
does not release the object object itself

Definition at line 56 of file DBConnection.m.

- (NSDictionary *) columnsForTable: (NSString *)  tableName

Returns a dictionary of column types keyed by column names

Parameters
tableNameName of the table to retrieve columns for

Definition at line 73 of file DBConnection.m.

- (BOOL) endTransaction: (NSError **)  outErr

Ends a transaction (in most cases, using -transaction: is preferred)

Definition at line 88 of file DBConnection.m.

Referenced by transaction:.

- (DBResult *) execute: (NSString *)  sql
substitutions: (id)  substitutions
error: (NSError **)  outErr 

Executes the given SQL query, returning a result set

Example usage:

[myConnection execute:@"SELECT *FROM mymodel WHERE id = $1"
substitutions:@[@1]];

Definition at line 46 of file DBConnection.m.

- (BOOL) executeUpdate: (NSString *)  sql
substitutions: (id)  substitutions
error: (NSError **)  outErr 

Executes the given SQL query returning whether or not it was successful.

Example usage:

[myConnection executeUpdate:@"INSERT INTO mymodel(id, name) VALUES($1, $2)"
substitutions:@[@2, @"foobar"]];

Definition at line 51 of file DBConnection.m.

Referenced by DBWriteQuery::executeOnConnection:error:.

- (BOOL) executeWriteQueriesInTransaction: (NSArray *)  queries
error: (NSError **)  outErr 

Provided by category DBConnection(DBQuery).

Definition at line 244 of file DBQuery.m.

References transaction:.

- (instancetype) initWithURL: (NSURL *)  URL
error: (NSError **)  NS_DESIGNATED_INITIALIZER 

Opens a connection to the database pointed to by URL

Definition at line 39 of file DBConnection.m.

References URL.

+ (id) openConnectionWithURL: (NSURL *)  URL
error: (NSError **)  err 

Opens a connection to the database pointed to by URL

Definition at line 25 of file DBConnection.m.

References _ConnectionClasses, and URL.

+ (void) registerConnectionClass: (Class)  kls

Registers a DBConnection subclass to be tested against URLs

Definition at line 17 of file DBConnection.m.

References _ConnectionClasses.

- (BOOL) rollBack: (NSError **)  outErr

Rolls back a transaction (in most cases, using -transaction: is preferred)

Definition at line 83 of file DBConnection.m.

Referenced by transaction:.

+ (NSString *) sqlForType: (DBType)  type

Returns a SQL type string for a type

Definition at line 118 of file DBConnection.m.

- (BOOL) tableExists: (NSString *)  tableName

Returns a whether a given table exists

Parameters
tableNameName of the table to check

Definition at line 68 of file DBConnection.m.

- (NSArray *) tableNames

Returns an array of names of tables in the database.

Definition at line 62 of file DBConnection.m.

- (BOOL) transaction: (DBTransactionBlock aBlock

Executes a block wrapped in a transaction

Definition at line 94 of file DBConnection.m.

References endTransaction:, and rollBack:.

Referenced by executeWriteQueriesInTransaction:error:.

+ (DBType) typeForClass: (Class)  klass

Returns a SQL type for a given class

Definition at line 181 of file DBConnection.m.

+ (DBType) typeForObjCScalarEncoding: (char)  encoding

Returns a SQL type for a given Objective-C scalar type encoding

Definition at line 157 of file DBConnection.m.

+ (DBType) typeForSql: (NSString *)  type

Inverse of sqlForType:

Definition at line 140 of file DBConnection.m.

Member Data Documentation

- (NSURL*) _URL
protected

Definition at line 42 of file DBConnection.h.

Property Documentation

- (NSURL*) URL
readatomicretain

Definition at line 44 of file DBConnection.h.

Referenced by initWithURL:error:, and openConnectionWithURL:error:.


The documentation for this class was generated from the following files: