Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios5 iphone应用程序中的sqlite3_Ios5_Sqlite_Xcode4.2 - Fatal编程技术网

Ios5 iphone应用程序中的sqlite3

Ios5 iphone应用程序中的sqlite3,ios5,sqlite,xcode4.2,Ios5,Sqlite,Xcode4.2,我在sqlite3表中构建。执行以下选择命令时: select us.saleSpecificProduct,us.fAtMall,u.name,u.gender,st.storeName from UsersSale us,Users u,Stores st where u.userID=us.userID and st.storeID=us.saleStoreID order by us.saleID 它在shell中工作正常,但是如果我把这个语句放在我的iphone应用程序中,我会

我在sqlite3表中构建。执行以下选择命令时:

select us.saleSpecificProduct,us.fAtMall,u.name,u.gender,st.storeName
  from UsersSale us,Users u,Stores st
 where u.userID=us.userID and st.storeID=us.saleStoreID order by us.saleID
它在shell中工作正常,但是如果我把这个语句放在我的iphone应用程序中,我会得到一个错误

/*
 * read items from the database and store in itemw
 *
 */
-(void)readItems {

if (!database) return; // earlier problems

// build select statement
if (!selStmt)
{
  const char *sql =  "select us.saleSpecificProduct,us.fAtMall,u.name,u.gender,st.storeName from UsersSale us,Users u,Stores st where u.userID=us.userID and st.storeID=us.saleStoreID order by us.saleID"; 
      if (sqlite3_prepare_v2(database, sql, -1, &selStmt, NULL) != SQLITE_OK)
    {
        selStmt = nil;
    }
当我执行应用程序时,在“sqlite3\u prepare\u v2”中出现错误 }


怎么了

也许可以尝试将参数放在单引号内

比如:

WHERE u.userID = 'us.userID' AND st.storeID = 'us.saleStoreID' ORDER BY us.saleID
此外,还应使用绑定来获取安全语句:

e、 g

NSString *strGet = @" . . . WHERE u.userID = ? AND st.storeID = ? ORDER BY us.saleID"

if(sqlite_prepare_v2(...) == SQLITE_OK)
{
    sqlite3_bind_int(stmtGet, 1, us.userID);
    sqlite3_bind_int(stmtGet, 2, us.saleStoreID);

    while(sqlite3_step(stmtGet) == SQLITE_ROW)
    {
        DatabaseDataObject *myDataObj = [[DatabaseDataObject alloc] init];

        myDataObj.objID = sqlite3_column_int(0);
        myDataObj.postcode = sqlite3_column_int(1);

        // add to parameter array of objects
        [myArr addObject:myDataObj];

        [myDataObj release];
    }
}