Building and using direct database queries is no longer necessary in XenForo 2. Instead, the XenForo developers have included a finder system, which is tied to their entity system.
An elementary example shown in the developer's manual is to find a user with a known user_id.
The first line calls the finder system using the entity
The returned value $user is not an array. Instead, $user is an entity object.
An elementary example shown in the developer's manual is to find a user with a known user_id.
PHP:
$finder = \XF::finder('XF:User');
$user = $finder->where('user_id', 1)->fetchOne();
The first line calls the finder system using the entity
XF:User
. Next, the where condition narrows the database search to the user_id equal to 1. Finally, the finder fetches one record from the database.The returned value $user is not an array. Instead, $user is an entity object.