Forums

PHP formating in db read action

chriso0258 17 Jun, 2015
Hello,

I'm having trouble with formatting a db read action condition. I have model ID enabled. I've tried numerous formats but here is the gist of the code I'm trying but can't get it right.

<?php 
return array('equipLoc.state_tag' => '$form->data['eastList']['state_tag']'); 
?>


Here's some additional information:
Table Name in db read action: its_equip_location
Model ID: equipLoc
Debug info:
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
            [memory] => 
            [prod_key] => 
            [purch_date] => 
            [warr_date] => 
            [surplus_date] => 
        )
)


Thanks for your help.
chriso0258 17 Jun, 2015
I didn't see a way of editing my post so let me make some corrections. The php code should read:

<?php 
return array('equipLoc.state_tag' => '$form->data['eastList']['its_equip_id']'); 
?>


I also just noticed in the debug that there is no "state_tag" variable from the original connection being sent to the form. Not sure why that is. Sorry for any confusion.
chriso0258 18 Jun, 2015
Ok, one last time. Sorry for all this confusion. I think I can now better clarify my problem which is I can't get the db reader to display the matching records from the table. Here is how the db reader is configured:

[attachment=0]db read 1.jpg[/attachment]

<?php 
return array('equipLoc.state_tag_loc' => $form->data['eastList']['its_equip_id']); 
?>


[attachment=1]db read 2.jpg[/attachment]

So, I set up a CCv5 connection in my menu to display a listing of equipment. When I click on the tag number of one of the equipment a CFv5 form displays the equipment information and grabs the location information from the its_ equip_location table. I can display the equipment information, but I can't get the location information to display. Is there something in the db reader I'm not configuring to display data?

Here is the debug information:

Array
(
    [cont] => lists
    [ccname] => eastEquipList
    [act] => edit
    [gcb] => 12
    [eastList] => Array
        (
            [its_equip_id] => 12
            [state_tag] => J70599
            [region_equip] => 1
            [site_equip] => 1
            [type] => PC
            [brand] => Compaq
            [model] => D500
            [serial_no] => US31JYGXA117
            [memory] => 
            [prod_key] => 
            [purch_date] => 
            [warr_date] => 
            [surplus_date] => 
        )

    [equipLoc] => Array
        (
            [0] => Array
                (
                    [state_tag_loc] => 12
                )

        )
)

Array
(
    [2] => Array
        (
            [DB Read] => Array
                (
                    [Queries] => Array
                        (
                            [0] => SELECT `equipLoc`.`state_tag_loc` AS `equipLoc.state_tag_loc` FROM `its_ equip_location` AS `equipLoc` WHERE `equipLoc`.`state_tag_loc` = '12'
                        )

                )

        )

)
chriso0258 18 Jun, 2015
Hello again,

I finally got some data printed out using the "How can I build a product list?" example. Thank you for that example. Now, my question is this. I was used to CFv4 where you could tell the db read action what columns to print. That made it easy to configure. Is the products list method the only way to print a list from the db reader or is there a simpler method. Please don't get me wrong, I'm ok using this method, but if there is a quicker means to just print out records I'd rather use that when that's all I want to do.

Thanks for your patience in all this.
GreyHead 19 Jun, 2015
Hi chriso0258,

The DB Read action in CFv5 has a 'Fields' box where you can add a list of columns to read - but I don't think that is your question as you've used it.

What is the 'product list method'?

Bob
GreyHead 22 Jun, 2015
Hi chriso0258,

Sorry. I'm still lost.

Do you have the data you need in the $form->data[' array']?
If so then you can print it out using a Custom Code element in the Designer tab - there is no equivalent to the built-in Data Displayer in CFv5 :-(

If you have got it and it isn't displaying what code are you using to display it?

Bob
chriso0258 22 Jun, 2015
Answer
Hello Bob,

Sorry for the confusion. I think I have this part resolved as i can get a record to display from the primary table. However, I'm having problems displaying data from other tables with foreign keys. I have another post regarding that. So, I'll close this post out. Thanks again for responding.
This topic is locked and no more replies can be posted.