This topic is locked

Lookup table - category control

7/8/2005 3:27:42 AM
PHPRunner General questions
author

Hi all!
It is possible setup as category control in lookup table fields from inner join tables (SQL query modyfied manually). Now I can't view thies fields on category control list.

admin 7/8/2005

What exactly is the question?

500281 7/8/2005

Sql query looks like this:
select `table1`.`id_table1`,

`table1`.`a1`,

`table1`.`a2`,

`table2`.`b1`

From `table1`

inner join `table2` on

`id_table1` = `id_table2`
In step 8 table1, field a1 I setup as lookup wizard.

I select This dropdown is dependent on ...

On category control I can't find field b1 from table2, only fields from table1
It is possible setup b1 as category control?

admin 7/11/2005

I see what you saying now.
Category control should be a field from the same table. PHPRunner cannot update fields in two tables simultaneosuly, all updatable fields should come from the same table.

500282 7/11/2005

Hi
But field b1 from table2 is using only for reading data as category control for other fields from table1.

How can I solve it?

admin 7/11/2005

I can recommend to create a dummy field in table1 to store category name. You can hide this field on list/view/search pages.
We'll add a feture in the next version of PHPRunner that simplifies creating dependent dropdowns when category field is not in the same table. Currently you can use a workaround I have suggested.

500283 7/12/2005

Hi
How can I fiell this dummy field automatic not manually?

Any idea?

admin 7/12/2005

This dummy field will be filled automatically. There is nothing to do manually.

500284 7/12/2005

I don't know haw can I do this.

Can you help me?

admin 7/12/2005

Hi,
this dummy field will be filled automatically for newly added records.

To fill dummy field for existing records use the following query:

update table1 inner join table2 on id_table1=id_table2 set dummy=table2.b1
500285 7/13/2005

OK this query ->

update table1 inner join table2 on id_table1=id_table2 set dummy=table2.b1



updates existing records, but how looks query that works with Phprunner and works automatically when adding new record???
Now query looks like this:

select `table1`.`id_table1`,

`table1`.`a1`,

`table1`.`a2`,

`table1`.`dummy`,

`table2`.`b1`

From `table1`

inner join `table2` on

`id_table1` = `id_table2`
admin 7/13/2005

Hi,
I'm not sure I fully understand your needs.
Please clarify what field you need to fill automatically, when it should be filled and what value should be written to it ?

What functionality do you expect from these dependent dropdowns ?

Give me some real life example.

500286 7/18/2005

Hi
Example:
Master Table Orders

Id_Order

Order

Assortment

Detail table Production

Id_Production

Order_P

Assortment_Part

In Phprunner for table Production SQL query looks like this:

select Production.Id_Production,

Production.Order_P,

Production.Assortment_Part,

Orders.Assortment

from Production

inner join Orders on

Order_P = Id_Order


Now field Assortment_Part I setup as Lookup wizard

and I need setup Assortment as Category control for this field.

But I can only using fields from table Production as Category control.
Is it clear?
Your suggestion is add for table Production dummy field that will be hold assortment. This field will work as category control. But how fill this dummy field automatically when I try add record for table Production?

admin 7/19/2005

If table Order holds Assortment value you do not need category control at all.
Instead of that you need to use WHERE expression to filter drop-down box content.
Here are required steps:

  1. Do not use INNER JOIN query. Use default query PHPRunner builds for you
  2. Define Master-Details relationship
  3. Make sure Master table info appears on Details table list page
  4. Save Assortment from Master table in Session variable (Production_list.php)

    see my changes in bold:
    <?php

    if($rsMaster)

    {

    $data=db_fetch_array($rsMaster);

    $_SESSION["Assortment"] = $data["Assortment"];

    ?>


5. When you define a lookup wizard for Assortment_Part field use WHERE expression:

"assortment_id = " . $_SESSION["Assortment"]

500287 7/25/2005

Hi
This not work. $_SESSION["Assortment"] always empty

When I setup to test

"assortment_id = 'u2cz'"

dropdown list for Assortment_Part work OK.

When I setup to test

$_SESSION["Assortment"] = 'u2cz';



and

"assortment_id = " . $_SESSION["Assortment"]

dropdown list for Assortment_Part NOT work.
I think problem is more complicated.

When I add new record for Production I don't know what Assortment will be.

Assortment will be know when I choose Order_P(Order_P from Production = Id_Order from Orders) from dropdown list.

admin 7/25/2005

Zavka,

  1. If Assortment field is a text field you need to add apostrophees while defining WHERE expressions:
    "assortment_id = '" . $_SESSION["Assortment"] . "'"
  2. Did you setup a Master-Details relationship between Order and Production tables? This schema will work only if you use Master-Details relationship.

500288 7/25/2005

I found this:

When I go -> Detail table Production -> Add record - dropdown list for Assortment_Part NOT work

When I go -> Master Table Orders -> Detail table Production for any record from list -> Add record - dropdown list for Assortment_Part WORK OK

What do You think about? <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=5277&image=1&table=forumreplies' class='bbc_emoticon' alt=':P' />

500289 7/25/2005

I found this:

When I go -> Detail table Production -> Add record - dropdown list for Assortment_Part NOT work

When I go -> Master Table Orders -> Detail table Production for any record from list -> Add record - dropdown list for Assortment_Part WORK OK

What do You think about? <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=5278&image=1&table=forumreplies' class='bbc_emoticon' alt=':P' />


Work but don't Ok

It takes assortment parts for selected and viewed Order

not proper for record you want to add to table Production

admin 7/25/2005

Zavka,
this schema works only if you go to Details table through the Master table.
Here is the recommended workflow:

  1. Proceed to Orders table and pick any Order to view Details
  2. On Details page click Add new to add new record
  3. Go back to list of Details
  4. Go back to Master table
  5. Pick another order and repeat steps 2-4.
    The whole idea of Master-Details relationship is to pick master table first and proceed to details after that.

500290 7/26/2005

Thanks a lot for help
I have only one question about this ->

We'll add a feture in the next version of PHPRunner that simplifies creating dependent dropdowns when category field is not in the same table. Currently you can use a workaround I have suggested.



It is or will be on TODO list?

admin 7/26/2005

Sure, I got it on my TO DO list.