这会导致此错误......
操作数应包含1列[UPDATE
record
SETlogo
=('', '','',4,0)WHEREid
='0']
if ($_FILES['logo']['name'] == '') {
$record->logo = $record->logo;
}
else{
// INSERTION WORKS FINE
}
如果有所作为,我也会使用Formo模块......
有没有办法完全从插入脚本中删除徽标,或者这样......因为$record->logo = $record->logo
会导致失败?
答案 0 :(得分:0)
$record->logo = $record->logo;
如果未设置$ record->徽标会导致错误..您必须至少说:
$record->logo = '';
但最好的办法是使用Validation::factory($_FILES)->check()
if ( $logo->check() ) {
// do your insert here
}
这只是我上次管理时的片段:
$logo = Validation::factory($_FILES);
$logo->rule('logo', 'Upload::not_empty')->rule('logo', 'Upload::type', array(':value', array('jpg', 'png', 'gif')));
if ( $logo->check() ) {
$logo = Upload::save($_FILES['logo'], NULL, 'assets/uploads/logo');
$image = ORM::factory('image')->where('id', '=', $id)->where('type', '=', 'logo')->find();
$path = explode('/', $logo);
$path = end($path);
$image->path = 'assets/uploads/logo/' . $path;
$image->playlist_id = $id;
$image->type = 'logo';
$image->save();
}