日期:2014-05-16 浏览次数:20594 次
 pldatabase的网站地址: 下面我翻译一下其最简单的入门知识,在项目过程中, 发现这些其实也够用, 但异常处理这些我还没引进来使用. 为存在数据库文件打开一个链接: 
http://plsqlite.narod.ru/http://code.google.com/p/pldatabase/?在这里可以下载和查看文档和代码.基本使用指南
创建一个链接
PLSqliteDatabase *db = [[PLSqliteDatabase alloc] initWithPath:  @"/path/to/database"];  
if (![db open])  
    NSLog(@"Could not open database"); 
?
更新操作可以使用 -[PLDatabase executeUpdate:]
if (![db executeUpdate: @"CREATE TABLE example (id INTEGER)"])  
    NSLog(@"Table creation failed");  
if (![db executeUpdate: @"INSERT INTO example (id) VALUES (?)", [NSNumber numberWithInteger: 42]])  
    NSLog(@"Data insert failed");  
?
执行查询操作可以使用 -[PLDatabase executeQuery:]. 该操作返回结果集是一个对象为PLResult的NSObject实例.使用方法如下
id<PLResultSet> results = [db executeQuery: @"SELECT id FROM example WHERE id = ?", [NSNumber numberWithInteger: 42]];  
while ([results next]) {  
    NSLog(@"Value of column id is %d", [results intF