Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » RADICORE Installation Issues » Existing data do not show up in LIST2
icon5.gif  Existing data do not show up in LIST2 [message #1081] Tue, 04 September 2007 09:35 Go to next message
bbkwon is currently offline  bbkwon
Messages: 13
Registered: August 2007
Junior Member
Hi,

I'm trying to use Radicore to manage existing database.
But I have found something interesting while I'm creating a LIST2 pattern.
Let's say I have two table A and B. A is senior to B and I have created a relationship between them.
When I creat LIST pattern for A or B. Both data shows up fine.
But when I open LIST2 screen of A, there is not B data at the bottom. But I know there are some B data for A.

Interestingly, if I ADD a B for A then it show up under A.

I'd like to know why this happens.
I guess Radicore keep track of something internally!

What do I need to do to see existing B data under A?
Is there data import functionality in radicore?

Thanks.
Re: Existing data do not show up in LIST2 [message #1082 is a reply to message #1081] Tue, 04 September 2007 10:16 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
You must have done something wrong as I can create a LIST2 screen which shows up existing data from the child table without any problems.

There is no need for a data import facility as the framework will use whatever data it finds in your database. You do not need to add the data using Radicore before Radicore will read it.

The only "tracking" that Radicore does is inside the LIST2 pattern itself where it takes the primary key of the parent (outer) table and uses it as the WHERE clause for the child (inner) table.

Try comparing what you have done with the tutorial at http://www.tonymarston.net/php-mysql/radicore-tutorial3.html #x_tree_level.step2


Re: Existing data do not show up in LIST2 [message #1083 is a reply to message #1082] Tue, 04 September 2007 10:42 Go to previous messageGo to next message
bbkwon is currently offline  bbkwon
Messages: 13
Registered: August 2007
Junior Member
I would agree with you if it shows all or nothing.
But a record I created in Radicore shows up and none of pre-existing ones.
If you look at the data, they are not different.
Since they share the same parent key.

I just can not understand this part!!


Thanks
Re: Existing data do not show up in LIST2 [message #1084 is a reply to message #1083] Tue, 04 September 2007 11:07 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
Then you need to step through with your debugger to see exactly what SQL statements are being issued. Alternatively you could use step 2 in http://www.tonymarston.net/php-mysql/infrastructure-faq.html #faq51

Re: Existing data do not show up in LIST2 [message #1085 is a reply to message #1084] Tue, 04 September 2007 23:16 Go to previous messageGo to next message
bbkwon is currently offline  bbkwon
Messages: 13
Registered: August 2007
Junior Member
I did sql trace and found this.

SELECT SQL_CALC_FOUND_ROWS * FROM course WHERE ( id='1' ) LIMIT 1 OFFSET 0 =>Count=1
SELECT SQL_CALC_FOUND_ROWS golfround.*, course.id FROM golfround LEFT JOIN course ON (course.id=golfround.courseid) WHERE golfround.id='1' LIMIT 25 OFFSET 0 =>Count=1

'course' is parent and 'golfround' is child.
What make me puzzled is 'golfround.id='1'.
It is supposed to be 'golfround.courseid='1'.

Here is a part of child tables dict.inc file.
// parent relationship details
$this->parent_relations[]= array('parent' => 'course',
'parent_field' => 'name',
'fields' => array('courseid' => 'id'));

I believe what it says is that 'courseid' field on child table is linked to 'id' field on parent.
It looks like the problem happens because Radicore uses field 'id' instead of field 'courseid' when it compose SQL above.
It may assumes the name of the parent's primary key is the same as child's foreign key. In this case, 'id'.

I'm pretty sure this is what is happening.
I have changed the name of primary key of the parent from 'id' to 'courseid' and LIST2 shows up correctly. And the SQL gets corrected to 'golfround.courseid='1'.

Is this what Radicore is written as?
I think it can/should get the name of the child's foreign key field by looking into the 'parent relationship details' info section in dict.inc file.
If I want Radicore take the child's field name instead of parent's, which file do I need to change?


Thanks
Re: Existing data do not show up in LIST2 [message #1086 is a reply to message #1085] Wed, 05 September 2007 06:21 Go to previous message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
The documentation clearly states at http://www.tonymarston.net/php-mysql/data-dictionary.html#$p arent_relations that the information in $this->parent_relations is only used to add JOIN clauses to an SQL statement. It is not used to modify the $where string which is passed from a parent table object to a child table object. So if the primary key of the parent table is "id=1" then that is what is passed to the child object. If the name of the corresponding foreign key on the child table is anything other than "id" then you will have to change it manually using code in the _cm_pre_getData() method.

The reason that this change in column names cannot be done automatically is that the child object does not know the name of the parent table (remember that there can be more than one parent). Even if it did how could that deal with the situation where there is more than one relationship between the same two tables, as with MNU_TRAN -> MNU_MENU and MNU_TRAN -> MNU_NAV_BUTTON?

This topic is discussed in database-design.html#primary.keys and database-design.html#foreign.key.names


Previous Topic: 'Build Directory' is not working!
Next Topic: PROBLEM AT LOGIN PAGE
Goto Forum:
  


Current Time: Thu Mar 28 13:18:31 EDT 2024

Total time taken to generate the page: 0.03339 seconds