[dokuwiki] Re: MySQL and Dokuwiki

On Wed, 16 Dec 2009 04:28:35 +0100
"M. Sabath" <msabath@xxxxxx> wrote:

Hi Markus,

> table name is "egw_adrress" 
> an the 
> column name is "subject" 
> 
> How do I ask mysql for the information?#

To get a link from the "subject" to your user you need a reference from one 
table to the other.
This is a commin field like username or something similar.

Here is the SQL statement:
$conf['auth']['mysql']['getGroups']   = "SELECT subject as `group`
                                                                    FROM 
egw_address g, egw_accounts u
                                                                WHERE 
u.account_id = g.account_id
                                                                      AND 
u.account_id='%{user}'";

The statement does the following: 
The result of the statement is a table which contains the field "subject" named 
as "group".
The data came from the two tables "egw_address" and "egw_accounts". For both 
tables
aliases were set ("g" and "u") to make life easier. Now comes the tricky part. 
We have to tell
MySQL how the two tables are connected; which row in egw_address belongs to 
which
row in egw_accounts. I assumed that  the column "account_id" exists in both 
tables. Keep
in mind that this relation must not be unique. A row in "egw_accounts" may have 
multiple
counterparts in "egw_address", but this depends on the dabase design.
Last but not least we have to make shure that obly groups that belong to our 
user will be
returned, so we add a condition to check that to the WHERE statement.

I hope my explanation will help you to play a bit with the statement and find 
one that works
for you. I could only provide a full statement, if I knew the complete database 
model.

 Best Regards
   Matthias
-- 
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: