Topic: Tons of questions about punbb ;)

Hello all
I m new to PHP programming but I m really interested and would like to learn more about punBB (may be I can help write some plugins later wink )

When I read the index.php , there are codes that I dont understand , can you explain ?

$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster, f.parent_forum_id FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND (f.parent_forum_id IS NULL OR f.parent_forum_id=0) ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());

Why there is the prefix such as c.id , c.cat_name , f.id ? The only thing I see in phpmyadmin is id , cat_name in the table categories ?

Re: Tons of questions about punbb ;)

I think it may stand for column but I could be totally off. Someone care to clear it up?

Re: Tons of questions about punbb ;)

It's to make the query a whole lot easier to read. The tables are used as "categories AS c", which means that c.id actually is categories.id. You have to specify the table when working with multiple tables in a query.

Re: Tons of questions about punbb ;)

oh , i see , thanks , but i dont see the declaration "categories AS c" in the query statement , is it a feature of mysql database ? or may it be declared somewhere at the beginning ?

PS :
I have used the mod : sub forum 1.0.4 and very satisfied but it will be much better if it shows the sub forum name in the description automatically (i know i can make it manually)
The mod has its bad config layout in the admincp : sub-forums are treated as same as forums . I want the layout to be :
forum 1
    subforum 1
    subforum 2
forum2

Can anyone guide me ? or show me which related files what i can modify myself
Thanks

forum

Re: Tons of questions about punbb ;)

mephis wrote:

oh , i see , thanks , but i dont see the declaration "categories AS c" in the query statement , is it a feature of mysql database ? or may it be declared somewhere at the beginning ?

nope, it is there: ''.$db->prefix.'categories AS c'

Re: Tons of questions about punbb ;)

Jansson wrote:

You have to specify the table when working with multiple tables in a query.

thats only required when you are referencing columns that multiple tables share (like id).  it really does make it much easier to (read /) maintain later on (or if you're looking at it for the first time).

Re: Tons of questions about punbb ;)

mephis wrote:

oh , i see , thanks , but i dont see the declaration "categories AS c" in the query statement , is it a feature of mysql database ? or may it be declared somewhere at the beginning ?

You need have a good lecture of MySQL documents smile

[no signature]

Re: Tons of questions about punbb ;)

vnpenguin wrote:

You need have a good lecture of MySQL documents smile

We are all born noobs... The rate at which you learn and your desire to become wise is what matters smile

Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation - Oscar Wilde