通过SQLite中的列名获取? [英] Get by column names in SQLite?

查看:73
本文介绍了通过SQLite中的列名获取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在从这样的语句中获取值:

Currently I am getting the values from statement like this:

[[NSString stringWithUTF8String:(char *)sqlite3_column_text(ReturnStatement,0)] retain];

我想通过输入像这样的列名来获取值:

I want to get the values by entering the column name like this:

[[NSString stringWithUTF8String:(char *)sqlite3_column_text(ReturnStatement,@"FirstColumn")] retain];

有什么办法吗?

推荐答案

查看 http://sqlite. org/c3ref/column_name.html .您将必须遍历查询返回的列索引,以将列名添加到数组或字典中,以供以后引用以指定名称提供给column_text函数的列索引来查找列索引,该函数只接受列索引作为整数参数.

Check out http://sqlite.org/c3ref/column_name.html. You will have to iterate over the column indices returned by the query to add the column names to an array or dictionary that you can reference later to lookup the column index given a name to provide to the column_text function which only accepts the column index as an integer parameter.

直接使用sqlite代替CoreData会为您解决的问题之一.

One of the problems of using sqlite directly instead of CoreData which will handle this for you.

这篇关于通过SQLite中的列名获取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆