Conforms to ORDAResult
Declared in ORDATable.h

Overview

The ORDATable protocol specifies methods that can be used to manage and retrieve results from a database table. Each table maintains a dictionary of result row objects (those returned by [ORDATableResult objectAtIndexedSubscript:]) indexed by ID (for example, rowid in the SQLite implementation) such that, for any given ID, the same pointer will always be returned. This dictionary is an instance of NSMutableDictionary_NonRetaining_Zeroing – thus, when there are no other references to the row object besides the dictionary’s, the object is removed from the dictionary and deallocated. Each row object is syncrhonized with the database such that changing the database changes the object and vice versa.

Tasks

Instance Methods

columnNames

the associated table’s field names

- (NSArray *)columnNames

Return Value

the associated table’s field names

Declared In

ORDATable.h

foreignKeyTableNames

the associated table’s foreign key’s names

- (NSArray *)foreignKeyTableNames

Return Value

the associated table’s foreign key’s names

Declared In

ORDATable.h

insertValues:

Inserts values into the table

- (id<ORDATableResult>)insertValues:(id)values

Parameters

values

an object containing the values

Return Value

the inserted row

Discussion

This method performs ‘INSERT INTO VALUES ()’ and then returns the result of ‘SELECT * FROM WHERE {primary key} = ’. The values are retrieved using [NSObject valueForKey:].

Warning: There is currently no way to insert only some columns.

Declared In

ORDATable.h

primaryKeyNames

the associated table’s primary key’s names

- (NSArray *)primaryKeyNames

Return Value

the associated table’s primary key’s names

Declared In

ORDATable.h

selectWhere:

Selects from the table

- (id<ORDATableResult>)selectWhere:(NSString *)format, ...

Parameters

format

the format string for the where clause

...

the format string arguments

Return Value

the selected rows

Discussion

This method runs ‘SELECT * FROM WHERE ’ on the table and returns the resulting rows.

See Also

  • [NSString stringWithFormat:]

Declared In

ORDATable.h

updateSet:to:where:

Updates a row in the table

- (id<ORDATableResult>)updateSet:(NSString *)column to:(id)value where:(NSString *)format, ...

Parameters

column

the field to update

value

the value to set the field to

format

the format string for the where clause

...

the format string arguments

Return Value

the updated rows

Discussion

This method runs ‘UPDATE SET = WHERE ’ and then returns the result of ‘SELECT * FROM WHERE ’.

Declared In

ORDATable.h