我有一個應用程序,我創建了一個帶有文件上傳的註冊表。好吧,文件上傳和創建的寄存器沒問題。用表單上傳字段編輯註冊表
我希望當用戶把一個文件,它會做更新。如果沒有,請不要更新包含文件路徑的字段。
但是,我需要編輯這個寄存器。 edditing時,我的文件上傳顯示一個錯誤:在 '字段列表' SQL查詢1054未知列 '陣':UPDATE societario
錯誤:SQLSTATE [42S22]:列未找到。 attorneys
SET nome
= '睾丸中editar',empresa
= '',filial
= '',unidade
= '能源公司',alcada
= 'ATE 10.000',validade
= '123123111',arquivo
=陣列,其中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'));
}
}
需要創建或編輯? –
那麼,因爲你得到的錯誤信息是在更新.... – andrewsi