Forums

Difficulty getting file from db read

chriso0258 14 Jul, 2015
Hello,

I have a custom code at the top of my onLoad event which will get the logged in user's ID (biNO). I have a db read event right after the custom code. It is enabled, its_staff table selected, multi-read = yes, enable model ID = no, Fields box left blank (I assume that means all fields will be read), and with the following code:

<?php 
return array('bi_no' => form->data['biNO']);
?>


I put a debugger and show stopper after the db read. Here's what it shows:
Array
(
    [cont] => lists
    [ccname] => EastTransfer
    [act] => edit
    [gcb] => 1
    [EastTransfer] => Array
        (
            [its_equip_id] => 1
            [state_tag] => J70141
            [region_equip] => 1
            [site_equip] => 1
            [type] => Printer
            [brand] => LEXMARK
            [model] => Z52
            [serial_no] => 9330415007abcdeff
            [memory] => 1 GB
            [prod_key] => asdfasdfsadfasdf
            [purch_date] => 07-21-2015
            [warr_date] => 07-27-2015
            [surplus_date] => 
        )

    [biNO] => bi01acr
    [0] => Array
        (
            [staff_id] => 1
            [bi_no] => bi01d35
            [name] => removed for privacy
            [region_staff] => 1
        )

    [1] => Array
        (
            [staff_id] => 2
            [bi_no] => bi01b07
            [name] => removed for privacy
            [region_staff] => 1
        )

    [2] => Array
        (
            [staff_id] => 3
            [bi_no] => bi01acr
            [name] => removed for privacy
            [region_staff] => 1
        )

    [3] => Array
        (
            [staff_id] => 4
            [bi_no] => bi01abs
            [name] => removed for privacy
            [region_staff] => 1
        )

    [4] => Array
        (
            [staff_id] => 5
            [bi_no] => bi01421
            [name] => removed for privacy
            [region_staff] => 2
        )
)


As you can see, the entire "staff" table is being displayed. All I want to retrieve is the one record that matches biNO, in this case it is bi01acr, the third record. What am I not configuring properly?

Thanks for your help.
chriso0258 17 Jul, 2015
Hello,

I was able to extract the information I needed using a foreach loop in a custom code following the db reader. However, using this method requires all the records from the db reader to first be loaded into an array which takes up more memory if you have a ton of records. Is there anyway to incorporate what is in a custom code into the db reader, such as the foreach statement?

Thanks.
GreyHead 17 Jul, 2015
Answer
Hi chriso0258,

That needs an extra $
<?php 
return array('bi_no' => $form->data['biNO']);
?>

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