我有一个应用程序,我创建了一个带有文件上传的寄存器。好的,文件上传和创建的寄存器很好。
我希望当用户放置文件时,它会进行更新。如果不是,请不要更新包含文件路径的字段。
但是,我需要编辑这个寄存器。编辑时,我的文件上传显示错误:
错误:SQLSTATE [42S22]:未找到列:1054 “字段列表” SQL 查询中的未知列“数组”societario
:更新。attorneys
SET nome
= 'teste editor', empresa
= '', filial
= '', unidade
= 'Energia', alcada
= 'Até 10.000', validade
= '123123111', arquivo
= 数组 WHERE societario
。attorneys
. id
='83'
我的创建控制器:
if($this->request->is('post')){
$targetFolder = 'societario/app/webroot/uploads/'; // Relative to the root
$tempFile = $this->request->data['Attorney']['arquivo']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $this->request->data['Attorney']['arquivo']['name'];;
move_uploaded_file($tempFile,$targetFile);
$this->Attorney->saveAll($this->request->data, array('fieldList' => array('nome','empresa','filial','unidade','validade', 'alcada', 'status')));
$this->Attorney->updateAll(
array('arquivo' => "'".$this->request->data['Attorney']['arquivo']['name'] ."'",),
array('id' => $this->Attorney->id));
我的编辑控制器:
编辑:修改了编辑控制器。解决方案在于以下答案。
$this->Attorney->id = $id;
$this->set('poderes',$this->Attorney->Power->find('list', array('fields' => 'resumo')));
if ($this->request->is('get')) {
$this->request->data = $this->Attorney->read();
} else {
if ($this->Attorney->save($this->request->data)) {
$this->Session->setFlash('Usuário editado com sucesso!', 'default', array('class' => 'flash_sucess'));
$this->redirect(array('action' => 'usuarios'));
}
}