This commit is contained in:
M.Scholz 2012-01-27 09:36:02 +01:00
parent d79b0d7b52
commit 5801c989ce
12 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
{\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf230
{\fonttbl\f0\fmodern\fcharset0 Courier;}
{\colortbl;\red255\green255\blue255;\red237\green245\blue255;\red245\green0\blue0;}
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\deftab720
\pard\pardeftab720
\f0\fs26 \cf0 \cb2 [09:02] <tud> Do propel has the option to automatically join tables with their foreign key? I have some tables and would like to join them all with their foreign keys\
[09:05] <\cf3 Jarda\cf0 > tud: you can do FooQuery::create()->joinWith('Foo.Bar')->find()\
[09:06] <Jarda> didn't really get what you mean\
[09:06] <tud> Is "Bar" the foreign key in your example?\
[09:07] <Jarda> yeah\
[09:07] <tud> thanks\
[09:08] <tud> dorn here xD\
[09:08] <tud> the problem is we need 2 join a lot of tables dynamicly\
[09:08] <tud> is there a best pratice\
[09:09] <tud> for example we get via get params ColumnA,TableA and ColumnB,TableB -> now we need 2 join those 2 tables and select the 2 coulmns\
[09:09] <tud> this needs 2 be done dynamicly\
[09:09] <Jarda> hmm.. ok\
[09:09] <tud> any ideas?\
[09:09] <Jarda> well\
[09:10] <Jarda> you could in your FooQuery class write a public function joinByParameters(array $params) \{\'a0foreach ($params as $parm) \{ $this->joinWith(...); \} return $this; \}\
[09:10] <Jarda> or something like that\
[09:10] <Jarda> depends on the specific use case\
[09:12] <tud> so the best way is 2 use joinwith where u give the column u wanna join on?\
[09:12] <Jarda> yeah, or actually it's the foreign key name you give as parameter\
[09:13] <Jarda> <foreign-key foreignTable="bar"><reference local="bar_id" foreign="id" /></foreign-key> and then you use ->joinWith('Foo.Bar');\
[09:13] <tud> what happens if u have done smith like this: tbl1->join with(tbl2.column) ->joinwith(tbl3.column)->join with(.... does that work?#\
[09:13] <Jarda> you can have multiple joins, yes\
[09:14] <tud> and he automatically detects how 2 join it? over multiple tables?\
[09:14] <Jarda> yes, it should work\
[09:16] <tud> for example if tbl1.A->tbl2.A and tbl1.B->tbl3.A but we join tbl1->join with(tbl2.A)->join with(tbl3.A) - this will work?\
[09:17] <Jarda> if the foreign keys are wrintten in the schema, it should work\
[09:17] <Jarda> try it out\
[09:18] <tud> k much thx if that works its really amazing work ;-) much thx 4 the help}

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 748 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB