0
親愛的社區。下面的代碼編譯好了,開始,但返回空數組。相同的代碼具有相同的返回。有人可以提出一些建議嗎?Mysql在可可中使用
-(NSArray *) mysqlDirectQuery:(NSString *)query
{
// query doesn't using now
NSMutableArray *rows = [[NSMutableArray alloc] initWithCapacity:0];
MYSQL *sql = mysql_init(NULL);
//mysql_options(sql, MYSQL_READ_DEFAULT_GROUP, "LibMySQL");
sql = mysql_real_connect(sql, "localhost", "root", "", "test2", 3306, NULL, 0);
if (sql != NULL) {
mysql_query(sql, "select * from Users");
MYSQL_RES *qResult = mysql_store_result(sql);
if (qResult != NULL) {
MYSQL_ROW row;
while (row == mysql_fetch_row(qResult)) {
[rows addObject:[NSArray arrayWithObjects:
[NSString stringWithCString:row[0] encoding:NSISOLatin1StringEncoding],
nil]];
}
mysql_free_result(qResult);
}
mysql_close(sql);
mysql_server_end();
}
NSArray *resultArray = [NSArray arrayWithArray:rows];
rows = nil;
return resultArray;
}
這是產品警告:語義問題:使用賦值結果作爲沒有括號的條件 – Alex 2011-01-27 23:04:43