调用delete()会导致服务器错误

时间:2015-10-11 07:04:01

标签: php silverstripe

为什么我的delete()在Silverstripe中导致服务器错误?以下是代码:

$product = Product::create();
$product = Product::get()->filter(array('Price' => 26.32));
$product->delete();     

以上是requireDefaultRecords()并在/ dev / build?flush

时运行

1 个答案:

答案 0 :(得分:7)

// Compile third-party dependencies separately for faster performance. gulp.task('browserify-vendor', function() { return browserify() .require(dependencies) .plugin(resolutions, '*') .bundle() .pipe(source('vendor.bundle.js')) .pipe(gulpif(production, streamify(uglify({ mangle: false })))) .pipe(gulp.dest('public/js')); }); // Compile only project files, excluding all third-party dependencies. gulp.task('browserify', ['browserify-vendor'], function() { return browserify('src/app.js') .external(dependencies) .plugin(resolutions, '*') .transform(babelify) .bundle() .pipe(source('bundle.js')) .pipe(gulpif(production, streamify(uglify({ mangle: false })))) .pipe(gulp.dest('public/js')); }); 将返回Product::get()->filter(array('Price' => 26.32)),而不是DataList对象。这是因为Product可以找到多个产品。即使Product::get()->filter()函数只找到一个项目,这仍然会返回DataList

您需要做的是浏览filter中的每个项目并删除每个项目。

DataList