2009年3月30日星期一

Re: [fw-mvc] form->getValues and file upload

Thomas Weidner wrote:
>
> There are only 2 possible ways:
> You can eighter get the database id BEFORE you receive/store the
> file... between validation and retrievement.
No way to be sure of the next id
> Or you have to rename the file manually AFTER you received it and you
> have the database id.
>
>> How can I do this without extending and overloading the getValue()
>> method of the Zend_Form_Element_File ?
>
> As I said before... between validation and retrievement.
>
> In case that the file is very big, you will have severe performance
> problems with this solution.
>
> Think different:
> 1.) Post
> 2.) Validation
> 2.) Create empty database entry and get db-id
> 3.) Set id on form and filename
> 4.) getValues()
>
Is this a good solution in your opinion ?
> As I said before...
> When you want to name the filename after the database id you have only
> 2 ways:
> Eighter get the id BEFORE retrievement, as shown above.
> Or rename the file AFTER you inserted into your database (possible
> performance problems).
>
Create empty database entry and get db-id ?
Do you think I have to do:
$id = $model->insert(array()) ... // with an empty array()
and then $model->update($form->getValues(), $id) ?

and if I have NOT NULL fields ?
if I have FOREIGN KEYS to other tables ?
if I have UNIQUE KEYS ??
If I have many people doing the same concurrent operations with
transactions ?

mmm .. IMHO $form->getValues() simply do not have to move files
and not even filter them in terms of renaming/scaling/watermarking etc ...
just validate them only for MaxFileSize, Count, MimeType, Extension ..
that's all

.. it's only my point of view ;)

thanks anyway

simone

没有评论: