我创建了一个表如下:
CREATE TABLE IF NOT EXISTS 'e!' (
`aa` int(11) unsigned NOT NULL auto_increment,
`showName` TEXT NOT NULL default '',
`startDateTime` DATETIME NOT NULL default '',
`endDateTime` DATETIME NOT NULL default '',
PRIMARY KEY (`aa`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
Run Code Online (Sandbox Code Playgroud)
然后尝试插入查询:
INSERT INTO e! (showname, startDateTime, endDateTime) VALUES('E! News ', '2012-05-03 19:00:00', '2012-05-03 20:00:00')
Run Code Online (Sandbox Code Playgroud)
而且由于!表名中的错误,我假设它!是mysql中的一个特殊字符.我试图逃避它,但查询仍然失败.
所以,我能有特殊字符,如!或&在表名?如果是,那么我可能不得不以某种方式对它们进行编码?
谢谢.
ios声称文件已被写入,但更改从未实际保存,就像它们保留在缓冲区中一样.我需要冲洗还是什么?
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *myFilePath = [[NSBundle mainBundle]
pathForResource:@"MyFile"
ofType:@"txt"];
NSLog(@"\n\nPath = \n%@", myFilePath);
NSString *myFileContents = [NSString stringWithContentsOfFile:myFilePath
encoding:NSUTF8StringEncoding
error:nil];
NSLog(@"\n\nContents = \n%@", myFileContents);
[@"This line will be written to file" writeToFile:myFilePath
atomically:YES encoding:NSUTF8StringEncoding error:nil];
NSString *changedContents = [NSString stringWithContentsOfFile:myFilePath
encoding:NSUTF8StringEncoding
error:nil];
NSLog(@"\n\nChanged Contents = \n%@", changedContents);
}
Run Code Online (Sandbox Code Playgroud)
输出:
Path =
/Users/hamzeh/Library/Application Support/iPhone Simulator/5.1/Applications/2B318687-A745-4CD9-85BA-52A01AB76F6E/savepersistentdata_tutorial.app/MyFile.txt
Contents =
This is a text file.
The file will be displayed on the iPhone.
That is all for now.
Changed Contents …Run Code Online (Sandbox Code Playgroud)