Customizing SMF > SMF Coding Discussion

Select ALL or just parent board

(1/4) > >>

colby2152:
How do I adapt the following PHP code to look at just one array of boards and no child boards?


--- Code: ---      // Retrieve all child boards, and child boards of child boards who inherit from parent
     // !! SLOW
     $request = $smcFunc['db_query']('',
  'SELECT requestedBoard.id_board
    FROM {db_prefix}boards AS requestedBoard
    INNER JOIN {db_prefix}boards AS childBoard ON (childBoard.id_parent = {int:parentId})
    LEFT JOIN {db_prefix}boards AS childOfChildBoard ON (childOfChildBoard.id_parent IN (childBoard.id_board))
    LEFT JOIN {db_prefix}boards AS childOfChildOfChildBoard ON (childOfChildOfChildBoard.id_parent IN (childOfChildBoard.id_board))
    WHERE requestedBoard.id_board IN (childBoard.id_board) OR
  requestedBoard.id_board IN (childOfChildBoard.id_board) OR
  requestedBoard.id_board IN (childOfChildOfChildBoard.id_board)',
    array(
'parentId' => $idboard,
    )
     );
--- End code ---

Now, how do I adapt it so that it takes all child boards, all grandchild, and all great-grandchild boards?

colby2152:
Anyone?

colby2152:
Bump...

Suki:
What exactly do you want?

What boards do you want to fetch?

The query there was built to specifically fetch child boards, if you only want to fetch parent boards then it is more easy to create a new query.

colby2152:

--- Quote from: Suki on September 18, 2012, 01:23:54 PM ---What exactly do you want?

What boards do you want to fetch?

The query there was built to specifically fetch child boards, if you only want to fetch parent boards then it is more easy to create a new query.

--- End quote ---

I want a separate query for fetching just the parent boards.

Navigation

[0] Message Index

[#] Next page

Go to full version