You are here: Re: edit/update - all in one PHP pages? « PHP Programming Language « IT news, forums, messages
Re: edit/update - all in one PHP pages?

Posted by Tim Van Wassenhove on 08/26/05 11:36

On 2005-08-26, Jim <jimyt@yahoo.com> wrote:
>> I have a hard time to understand why you would want to have a editfred
>> if you also have a update/add/delete script? What does the edit script
>> add of extra value?
>
> Here's how I currently name my scripts:
>
> view*.php - viewing data only
> edit*.php - an editable form with data populated ready for changing
> new*.php - blank form ready for new record entry
> update*.php - processes contents passed from the edit script
> create*.php - processes contents passed from the new script
> delete*.php - deletes a specific record

Each task is spread over two pages now. And as you mentionned
already, you now introduced the problem that you have to share data
between the two pages.

>> You could make a base script/class that shows the details of a fred
>> form. Depending on the "mode" it also show existing values and decided
>> which input controls it should show... mode=edit for add/update.
>> mode=read for enquire/delete.
>
> This is advocating the "all in one" script approach, which I must admit
> I don't like the thought of but it is clearly the most logical. What's
> the overhead like for the extra parsing the interpreter needs to do? If
> I combine the files I'm probably gonna end up with a single php file
> around 150% bigger.

No it's not advocating "all in one". It advocates that you group
everything that logically belongs to each other together.

Eg: An "insert" script first displays empty fields (meaby a couple of
default values are filled in), and then inserts them into a database.
An update script displays fields (with existing values) and then updates
the database.

They have in common that in both cases you have to display a form with
fields (and meaby values). They are distinct in the processing that is
performed after the data is posted.

Therefor i advocate to have an "edit" base that shows the form (with
eventual values). And then make your insert/update an extension
(inheritance) of that edit base.

If you now change your base a little, you can introduce the concept of
a read only-field. This allows you to use the base also for
enquire/delete (where you first want to display the actual record).
Thus, an enquire/delete script also extends the base edit. Once
again, they have a different "process posted data" implementation.


--
Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация