[Typo3] Database Relation in extension
Urs Weiss
uweiss at redline-webdesign.ch
Wed Jan 26 10:14:30 CET 2005
Am Dienstag, den 25.01.2005, 16:02 +0100 schrieb Bernhard Kraft:
> Urs Weiss wrote:
>
> > Hello,
> >
> > I started a new extension in the kickstarter today and now i run into a
> > strange problem.
> >
> > 1. I made a new table (tx_icrcardealer_marks) where the names of car
> > marks are stored. Selected column "mark" as lable.
>
> I think you don't mean "_marks" but "_brands" the english tranlsation
> for the german word "marke" (BMW, Audi, Ford) is "brand"
>
he he, yes, have to change that. Bad translator....
> >
> > 2. Created an other table (tx_icrcardealer_cars) with the "Field type"
> > to "Database relation".
> >
> > 3. "Create relation to table" set to "tx_icrcardealer_marks"
> >
> > 4. "Type" set to "Selectorbox, select global" because the marks are
> > stored at pid 0
> >
> > But after installing the Extension and filling in the marks i only see
> > one empty entrie in the list (because "Add a blank item to the selector"
> > is checked)
>
> Did you check this as an administrator or as an user ?
>
> Because if you are a user you probably didn't allow the user to have read
> access on the referenced table ...
>
Did it as admin.
I now debugged the exactly SQL query and now the problem is clear.
The config for "Selectorbox, select global" is:
"foreign_table" => "tx_icrcardealer_marks",
"foreign_table_where" => "ORDER BY tx_icrcardealer_marks.mark",
Then the query is:
SELECT tx_icrcardealer_marks.uid,tx_icrcardealer_marks.mark FROM
tx_icrcardealer_marks,pages WHERE pages.uid=tx_icrcardealer_marks.pid
AND NOT pages.deleted AND 1=1 ORDER BY tx_icrcardealer_marks.mark
The important part is:
WHERE pages.uid=tx_icrcardealer_marks.pid
tx_icrcardealer_marks.pid ==> is 0 because they are in the root page
pages.uid ==> is never 0 because autoincrement starts always at 1
Don't think this is a bug... (or is it??) but is "global (with
exeption)" and the docs are false.
Greets
Urs
More information about the TYPO3-english
mailing list