我一直在使用「標籤」做了一個模塊,每個標籤調用這樣一個組件:獲取並返回ID執行「編輯」行動
include_component('logotipo', 'index');
現在,這是該組件的代碼:
class logotipoComponents extends sfComponents {
public function executeIndex(sfWebRequest $request) {
$id_empresa = $this->getUser()->getGuardUser()->getSfGuardUserProfile()->getIdempresa();
$this->sdriving_logotipo = Doctrine_Core::getTable('SdrivingLogotipo')->createQuery('a')->leftJoin('a.SdrivingEmpresa e')->where('e.idempresa = ?', $id_empresa)->execute();
}
}
這是模板_index.php
:
<?php if ($sdriving_logotipo->count() > 0): ?>
<div class="span3">
<span class="gris">Vista previa</span>
<?php echo image_tag('/uploads/' . $sdriving_logotipo[0]->getArchivo()); ?>
</div>
<?php else: ?>
<div class="alert alert-block">
<h4><?php echo __('Información!') ?></h4>
<?php echo __('No se ha subido ningún logotipo aún. Haga clic en el botón "Subir nuevo" para crear uno.') ?>
</div>
<?php endif; ?>
此代碼工作正常,但我需要多一點。我需要在這裏做的是更新logotipo上傳一個新的,並從文件系統中刪除存在,也從數據庫或只是編輯現有的記錄和更新值。現在需要看看這個schema.yml
:
SdrivingEmpresa:
columns:
idempresa:
type: integer(4)
unsigned: true
primary: true
autoincrement: true
idlogotipo:
type: integer(4)
unsigned: true
primary: true
nombre_empresa:
type: string(250)
notnull: true
ruta_emp:
type: string(45)
notnull: true
autoincrement: false
relations:
SdrivingLogotipo:
local: idlogotipo
foreign: idlogotipo
type: one
SdrivingEmisor:
local: idempresa
foreign: idempresa
type: many
SdrivingMaquina:
local: idempresa
foreign: idempresa
type: many
SdrivingOperador:
local: idempresa
foreign: idempresa
type: many
SdrivingTurno:
local: idempresa
foreign: idempresa
type: many
SfGuardUserProfile:
local: idempresa
foreign: idempresa
type: many
SdrivingLogotipo:
columns:
idlogotipo:
type: integer(4)
unsigned: true
primary: true
autoincrement: true
archivo:
type: string(250)
relations:
SdrivingEmpresa:
local: idlogotipo
foreign: idlogotipo
type: many
考慮這一點,如果我選擇第一個選項,然後我需要建立一個查詢從數據庫獲取文件名,然後刪除文件系統中的文件,上傳新文件和用上傳文件的新ID更新SdrivingEmpresa
表。在這種情況下,我不知道如何獲取ID以及在哪裏編寫這些操作的邏輯:在protected function processForm(sfWebRequest $request, sfForm $form) { }
?在'doSave($ con = null){}'在SdrivingLogotipoForm.class.php
?哪裏?
任何幫助?