Forums

How to set up db relations in db reader

chriso0258 18 Jun, 2015
Hello,

I have a table that has foreign keys to other tables. For example, the picture below shows a status code of 3. That is what is in the status code column of the locations table. It is a foreign key to the status table. A three in the status table is "Standalone".

I noticed in the db reader there is a tab to set up relationships. Does that mean I can set up a relationship to the status table and have "Standalone" print out instead of a 3? If so, how would I configure the db reader to do this? In this example the status_loc column in the locations table is the foreign key to the equip_status_id (primary key) in the status table.

[attachment=0]db relations.jpg[/attachment]

Hope this makes some sense.

Thanks for your assistance.
chriso0258 19 Jun, 2015
Hello again,

Ok, I'm figuring out the relationship part. I decided to set up the relationship in the CCv5 connection. Regardless of whether I set it up in the connection or through the db reader, I get the following multiple arrays:

So, how do I write the php code to display the results I've described in the above post? There may be multiple lines if the equipment has been in multiple locations. That is why in the code below there are two entries in the array. So, in other words, in the picture above where the status code is 3, I want to print out Standalone on line one and State Network on line two. The debug shows I'm pulling the correct information but I don' t know how to format it. Will I need to use a foreach statement?

Thanks so much for helping to clear this up.

Array
(
    [cont] => lists
    [ccname] => eastEquipList
    [act] => edit
    [gcb] => 1
    [eastList] => Array
        (
            [its_equip_id] => 1
            [state_tag] => J70141
            [region_equip] => 1
            [site_equip] => 1
            [type] => Printer
            [brand] => LEXMARK
            [model] => Z52
            [serial_no] => 9330415007
        )

    [location] => Array
        (
            [0] => Array
                (
                    [its_location_id] => 1
                    [state_tag_loc] => 1
                    [status_loc] => 3
                    [region_loc] => 1
                    [site_loc] => 1
                    [building] => B2
                    [room] => MAILROOM
                    [dated_entered] => 3/16/2015
                    [date_moved] => 
                    [staff_id_loc] => 1
                )

            [1] => Array
                (
                    [its_location_id] => 51
                    [state_tag_loc] => 1
                    [status_loc] => 1
                    [region_loc] => 1
                    [site_loc] => 1
                    [building] => A
                    [room] => AC-101
                    [dated_entered] => 6/19/2015
                    [date_moved] => 6/19/2015
                    [staff_id_loc] => 1
                )

        )

    [status] => Array
        (
            [0] => Array
                (
                    [equip_status_id] => 3
                    [status] => Standalone
                )

            [1] => Array
                (
                    [equip_status_id] => 1
                    [status] => State Network
                )

        )
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger