我一直在使用“标签”做了一个模块,每个标签调用这样一个组件:获取并返回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
?哪里?
任何帮助?