我使用php 5.2.9作为xampp安装的一部分.我正在为我的webapp使用codeigniter框架.当我调用DateTime :: add时,Call to undefined method会显示错误.我的代码是......
$date_now = new DateTime();
$formatted_date = $date_now->format('Y-m-d H:i:s');
$expiry_date = $date_now->add(new DateInterval('P1Y'));
Run Code Online (Sandbox Code Playgroud)
显示的错误是......
Fatal error: Call to undefined method DateTime::add() in C:\webapps\first\system\application\models\model_first.php on line 25
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?该DateTime::format方法在这里工作正常.
问候
我刚开始使用核心数据.我想设置一个预先填充的数据库.我在某处读到核心数据在运行核心数据应用程序时会创建一个sqlite文件.我不知道在哪里寻找它.
我按照此博客上的说明进行操作,但未在指定目录位置/Users/<Username>/Library/Application Support/iPhone Simulator/User/Application/<Application GUID>/Documents/<database name.sqlite>或应用程序目录中找到sqlite文件.
这是我的persistentCoordinator代码.
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (__persistentStoreCoordinator != nil)
{
return __persistentStoreCoordinator;
}
NSString *storePath = [[[self applicationDocumentsDirectory] path] stringByAppendingPathComponent:@"coredata.sqlite"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:storePath]) {
NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:@"coredata" ofType:@"sqlite"];
if (defaultStorePath) {
[fileManager copyItemAtPath:defaultStorePath toPath:storePath error:NULL];
}
}
NSURL *storeURL = [NSURL fileURLWithPath:storePath];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
NSError *error = nil;
__persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self …Run Code Online (Sandbox Code Playgroud) 我已经close()为所有Backbone视图实现了一个简单的方法,当不需要/需要重置时,它会处理视图.
Backbone.View.prototype.close = function() {
if (this.onClose) {
this.onClose();
}
this.remove();
this.unbind();
};
NewView = Backbone.View.extend({
el: '#List ul',
initialize: function() {},
render: function() {
_(this.collection.models).each(function(item) {
this.renderChildren(item);
}, this);
},
renderChildren: function(item) {
var itemView = new NewChildView({ model: item });
$(this.el).prepend(itemView.render());
},
onClose: function() {
this.collection.reset();
// I want to remove the child views as well
}
});
NewChildView = Backbone.View.extend({
tagName: 'li',
render: function() {
}
});
Run Code Online (Sandbox Code Playgroud)
现在,当我删除父视图时,我还想删除所有子视图.任何想法我怎么能这样做而不循环通过像这样的模型....
_(this.collection.models).each(function(item) {
item.close();
}, this);
Run Code Online (Sandbox Code Playgroud) 我正在创建一个简单的产品搜索webapp,用户可以根据价格,免费送货,名称,商店等过滤他收藏的购物产品.
我希望实现自定义搜索过滤器功能,用户可以在其中创建搜索过滤器,然后保存以供以后使用.搜索过滤器是这样的:
有人可以让我了解用于在数据库中存储此类搜索过滤器的数据库模式.我应该将mysql子句存储在数据库中,如"WHERE price <1000","WHERE free_delivery = 1"......或者可以创建这样的字段.
我有一个像"; a; b; c ;; e"这样的字符串.请注意,之前有一个额外的分号e.我要被拆分的字符串a,b,c;,e.但它被分裂样a,b,c,;e.
我的代码是
var new_arr = str.split(';');
Run Code Online (Sandbox Code Playgroud)
我能在这做什么来获得我想要的结果?
问候
我有以下代码......
$('#item_' + code + ' .delete').hide();
$('#item_' + code + ' .deleting').show();
$('#item_' + code).slideUp(400, function() {
$(this).remove();
$('#top .message').html('Item has been deleted');
});
Run Code Online (Sandbox Code Playgroud)
我想保存我在变量中使用的选择器,并使用它来执行操作,而不是每次都搜索DOM.
所以我像这样保存选择器......
var saved = $('#item_' + code);
Run Code Online (Sandbox Code Playgroud)
但是,如何更改其余代码?我对jQuery不太熟悉,因此想知道如何做到这一点.这会有用......
$(saved).(' .delete').hide();
$(saved).(' .deleting').hide();
$(saved).slideUp(400, function() {
$(this).remove();
$('#top .message').html('Item has been deleted');
});
Run Code Online (Sandbox Code Playgroud) 我在骨干文档中读到调用collection.reset()清除了集合.我想知道它是否也删除了模型,还是继续存在于内存中?
如果没有删除它们是否有更简单的方法来删除集合中的所有模型而不重复模型和调用model.remove()?
我正在访问的Web服务发送以下响应...
<strong>result</strong>
Run Code Online (Sandbox Code Playgroud)
如何剥离这些编码标签的字符串?
我刚开始玩Xcode 4.3中的Master-Detail视图模板,我正在尝试更改master的背景颜色并将其设置为颜色渐变.这是我尝试过的:
Colors.m
#import "Colors.h"
@implementation Colors
+ (UIColor *) navigationMenuGradientTop
{
return [UIColor colorWithRed:213.0f/255.0f green:91.0f/255.0f blue:92.0f/255.0f alpha:1.0f];
}
+ (UIColor *) navigationMenuGradientBottom
{
return [UIColor colorWithRed:188.0f/255.0f green:0.0f/255.0f blue:1.0f/255.0f alpha:1.0f];
}
+ (CAGradientLayer *) navigationMenuGradient
{
NSArray *colors = [NSArray arrayWithObjects:(id)self.navigationMenuGradientTop, self.navigationMenuGradientBottom, nil];
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.colors = colors;
return gradientLayer;
}
@end
Run Code Online (Sandbox Code Playgroud)
MasterViewController.m
import "Colors.h"
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
CAGradientLayer *bgLayer = [Colors navigationMenuGradient];
bgLayer.frame = tableView.bounds;
[tableView.layer insertSublayer:bgLayer …Run Code Online (Sandbox Code Playgroud) 正如标题所说,我想根据指定容器的宽度和高度截断用户输入的文本字符串.我的规范是截断字符串,Read More在最后显示一些消息,当用户点击它时,文本向下滑动.
更新:啊!忘了一件事.它也应该处理多字节字符.
有人可以说明我有什么选择吗?jQuery插件还是一些漂亮的jquery片段?
感谢致敬
backbone.js ×2
jquery ×2
php ×2
string ×2
core-data ×1
datetime ×1
ios ×1
iphone ×1
javascript ×1
mysql ×1
sqlite ×1
truncate ×1
uitableview ×1
xcode4 ×1
xcode4.3 ×1