Ask a Question related to PHP Development, Design and Development.
-
Joop #1
master - detail
Hello everyone,
I'm new on this list and have been working for quite a while on a PHP app
that will make an HTML frontend for a PostgreSQL dbms. Works fine so far
but I'm having a little trouble with master - detail screens. My db
(roughly) has a hierarchical structure, something like
BAND -> RECORD -> SONG
When I display the record, band should be displayed on top of the screen.
When song is displayed, band and record should be displayed. (the real app
has more than 3 layers, but the idea is the same).
At the moment I use something like storing current band, current record in
a serialized _SESSION variable. It works, but not very smoothly because
PHP (or actually HTTP) has no idea of history, descent (the current screen
doesn't know what the previous screen was).
So I'm struggling a bit with this. Are there any "standard" solutions for
this master - detail setup? I found a lot on macromedia, but I don't use
that, it's just Vim on Linux.
TIA for any pointers / help!
Joop Guest
-
Datagrid Master/Detail
Hi, I have a Datagrid populated from a Remote Object -Select query- and I looking for a master/detail application to show the details in a... -
master detail set php
I am having problems with the mater detail sets. I create a master detail set and use data from 2 tables linked together with a where clause. But... -
Can I delete from the detail of a master/detail datagrid?
Hi Mark, As for the delte certain items in the detailed grid items in MASTER/DETAIL grids. Here are my suggestions; The DataGrid, DataList or... -
Master Detail detail
Dear gurus, I have got a scenario where I have a master table its detail table its detail table. How to implement this using Data Grid or is... -
Master Detail Entry
How can I make a transactions table type entry using ASP. Say for example in an invoice the no of items ordered may vary invoice to invoice. (The... -
Erwin Moller #2
Re: master - detail
Hi Joop,
I am not completely sure I understand your problem.
If I don't forget the rest. :-)
Joop wrote:
Nothing 'standard' about it. Just normal relations in your database, so just> Hello everyone,
>
> I'm new on this list and have been working for quite a while on a PHP app
> that will make an HTML frontend for a PostgreSQL dbms. Works fine so far
> but I'm having a little trouble with master - detail screens. My db
> (roughly) has a hierarchical structure, something like
>
> BAND -> RECORD -> SONG
>
> When I display the record, band should be displayed on top of the screen.
> When song is displayed, band and record should be displayed. (the real app
> has more than 3 layers, but the idea is the same).
>
> At the moment I use something like storing current band, current record in
> a serialized _SESSION variable. It works, but not very smoothly because
> PHP (or actually HTTP) has no idea of history, descent (the current screen
> doesn't know what the previous screen was).
>
> So I'm struggling a bit with this. Are there any "standard" solutions for
> this master - detail setup? I found a lot on macromedia, but I don't use
> that, it's just Vim on Linux.
'good programming practice'.
Let me explain:
You have a certain depth in your structure, right?
And I guess you have certain PHP-scripts that display information on a band,
or a record, song, etc. Right?
In that case I do not see the problem retrieving the information in the
hierarchy.
Let's take your example: BAND -> RECORD -> SONG
Supose you call a page showSongDetails.php?songid=456
where the songid in your db is 456
If your database is set up in a comprehensive way, the table that stores
songid (lets call it tblsong), also stores a reference (foreign key) to
your recordtable (tblrecord).
Same goes for tblrecord to tblband.
In that way you can say for every song, of which band it is, simply by:
SELECT bandid, bandname, etc etc FROM tblband WHERE
(bandid=(SELECT bandid FROM tblsong WHERE songid=$songid));
in which $songid must of course be replaced by 456
Hope that helps.
Good luck,
Erwin
>
> TIA for any pointers / help!Erwin Moller Guest
-
Joop #3
Re: master - detail
On Tue, 02 Sep 2003 14:16:27 +0200, Erwin Moller wrote:
No, you understood it perfectly but I oversimplified the question, let me> Hi Joop,
>
> I am not completely sure I understand your problem. If I don't forget
> the rest. :-)
try again.
<big snip>
I only used the band -> record -> song setup as an example and a bad one,> In that way you can say for every song, of which band it is, simply by:
> SELECT bandid, bandname, etc etc FROM tblband WHERE
> (bandid=(SELECT bandid FROM tblsong WHERE songid=$songid));
sorry. Here's a better one (almost the real situation).
I have these tables
customer (key customer-id)
employee (foreign keys customer-id and person-id)
person (key person-id)
the relations are:
customer >-<< employee >>-< person
so a customer can have 0 or more employees and a person can be 0 or more
employees (can have 0 or more jobs). There's more, an employee can call in
sick 0 ore more times and a doctor can store 0 or more medical records on
a person, but the core is cust / emp / person.
In my PHP app, there are two routes that lead to employee, via customer
and via person. When coming from customer the screen should have customer
+ employee fields, when coming from person it should have person +
employee fields. So my app has to determin where it's coming from, and
that information table is not in a table. That's why I use session
variables now, but the nature of HTTP (stateless) and browsers make this
difficult to handle.
Hope this is a bit more clear. Has anybody else done this kind of thing in
PHP? TIA!
Joop Guest
-
Erwin Moller #4
Re: master - detail
Joop wrote:
Hi Joop,
(Ben jij nederlands? / Are you Dutch?)
I am. :-)
Okay, that is clear.> On Tue, 02 Sep 2003 14:16:27 +0200, Erwin Moller wrote:
>>>> Hi Joop,
>>
>> I am not completely sure I understand your problem. If I don't forget
>> the rest. :-)
> No, you understood it perfectly but I oversimplified the question, let me
> try again.
>
> <big snip>
>>>> In that way you can say for every song, of which band it is, simply by:
>> SELECT bandid, bandname, etc etc FROM tblband WHERE
>> (bandid=(SELECT bandid FROM tblsong WHERE songid=$songid));
> I only used the band -> record -> song setup as an example and a bad one,
> sorry. Here's a better one (almost the real situation).
>
> I have these tables
>
> customer (key customer-id)
> employee (foreign keys customer-id and person-id)
> person (key person-id)
>
> the relations are:
>
> customer >-<< employee >>-< person
>
> so a customer can have 0 or more employees and a person can be 0 or more
> employees (can have 0 or more jobs). There's more, an employee can call in
> sick 0 ore more times and a doctor can store 0 or more medical records on
> a person, but the core is cust / emp / person.
You can handle this in 2 'main' ways.>
> In my PHP app, there are two routes that lead to employee, via customer
> and via person. When coming from customer the screen should have customer
> + employee fields, when coming from person it should have person +
> employee fields. So my app has to determin where it's coming from, and
> that information table is not in a table. That's why I use session
> variables now, but the nature of HTTP (stateless) and browsers make this
> difficult to handle.
>
But I guess you figured that out yourself already. :-)
Maybe it help you when somebody else comments on it.
Let me clarify:
1) Just create 2 PHP-pages.
One for the route from customer (cust_empl.php),
One for the route from person (pers_empl.php).
This has the big advantage that you logically devide the routes and have the
possibility to do extra graphics/information/etc depending on the route.
I can imagine that you have to create more info depending on the route in
the future. In this way things are implemented easier/cleaner than with
if/then/else constructs of course.
And if a big chunk of the data is the same: Just make an include of it
(empl_view_incl.php) and keep the (breadcrumps??) logic out of it and in
the separate files (=cust_empl.php and pers_empl.php).
2) Store the state in _SESSION as you described and use already.
The fact that HTTP-protocol is stateless is excactly WHY sessiondata is
invented in the first place.
You use probably the _SESSION-array already to store other information I
guess???
So nothing wrong with your current approach I think.
I would advise you to stick to it unless one of the reasons in 1) is
compelling enough to switch.
Hope this helps.> Hope this is a bit more clear. Has anybody else done this kind of thing in
> PHP? TIA!
I am sure you can find literature for both approaches if you look for it.
I have done a lot of coding like this and have a very pragmatic approach:
Sit back, think it over, and pick whatever solution makes the most sense to
you.
Regards and good luck,
Erwin
Erwin Moller Guest



Reply With Quote

