PHP:
/**
* Gets all attachments (and data) matching the given conditions
*
* @param array $conditions
* @param array $fetchOptions
*
* @return array
*/
public function getAttachments(array $conditions = array(), array $fetchOptions = array())
{
$whereConditions = $this->prepareAttachmentConditions($conditions, $fetchOptions);
$sqlClauses = $this->prepareAttachmentFetchOptions($fetchOptions);
$limitOptions = $this->prepareLimitFetchOptions($fetchOptions);
return $this->fetchAllKeyed($this->limitQueryResults(
'
SELECT attachment.*, attachment_data.*
' . $sqlClauses['selectFields'] . '
FROM xf_attachment AS attachment
INNER JOIN xf_attachment_data AS attachment_data ON
(attachment_data.data_id = attachment.data_id)
' . $sqlClauses['joinTables'] . '
WHERE ' . $whereConditions . '
' . $sqlClauses['orderClause'] . '
', $limitOptions['limit'], $limitOptions['offset']
), 'node_id');
}
This query is used to fetch attachments. The fetchAllKeyed function is used, and oddly the key it uses is node_id.
The node_id key does not exist in the xf_user, xf_attachment or xf_attachment_data tables and these are (by default) the only tables available to this function.
I have a suspicion that this was a copy/paste error and the key should actually be 'attachment_id'.