XenForo developer

fetchOptions is usually referenced in the controller that calls that function in the model.

It usually is an array that contains things such as the tables to be joined, sort order.

Later on in that model function you will see how fetchOptions is processed. It's processed by another function and essentially returns the SQL conditions to be used in the query.

It's a great way of doing things. In the context of fetching all users, sometimes you'd need your user data to be joined with their profile data, other times you wouldn't. So rather than two different blocks of code, XF will use the same function but ad just its output using the fetchOptions.

I get why these are here, now. I'm still a little bit hazy... but I thought I would ask to help achieve something I'm working on.

If I wanted to make more data available to the array of posts in a thread by joining to another table, how would I go about this using this constants? I can extend the thread controller index to add extra join data to the fetchOptions array, I can extend the post model to add additional prepareJoinOptions, but I want to be sure of how I can trigger this off with an additional constant, using XenForo_Model_Post::FETCH_MY_DATA.

I need to understand whether this is possible, and if it is how to do it so I don't prevent other add-on developers doing the same thing.

My alternative is to grab my data and slice it into the existing posts array, but this sounds like it could be more elegant and would save a db query.

EDIT: These are the existing constants, with mine added at the bottom:

Well-known member

I get why these are here, now. I'm still a little bit hazy... but I thought I would ask to help achieve something I'm working on.

If I wanted to make more data available to the array of posts in a thread by joining to another table, how would I go about this using this constants? I can extend the thread controller index to add extra join data to the fetchOptions array, I can extend the post model to add additional prepareJoinOptions, but I want to be sure of how I can trigger this off with an additional constant, using XenForo_Model_Post::FETCH_MY_DATA.

I need to understand whether this is possible, and if it is how to do it so I don't prevent other add-on developers doing the same thing.

My alternative is to grab my data and slice it into the existing posts array, but this sounds like it could be more elegant and would save a db query.

EDIT: These are the existing constants, with mine added at the bottom:

Well-known member

Well you've got an illustration of a typical use in this topic. Binary numbers are also used in very low level operations, especially when one manipulates binary data, sometime related to the OS, or when one seeks performance in complex calculus.