Hello!
I have tried to code the custom query to search through a many to many related field but it always returns 0 results and doesn’t show any errors.
I want to search by the Account Name in a Project, and they are related with a Many to Many relationship.
In custom\modules\Project\metadata\searchdefs.php I have:
'accounts' =>
array (
'type' => 'link',
'label' => 'LBL_ACCOUNTS',
'width' => '10%',
'default' => true,
'name' => 'accounts',
),
And in custom\modules\Project\metadata\SearchFields.php:
'accounts' =>
array (
'query_type' => 'format',
'operator' => 'subquery',
'subquery' => 'SELECT projects_accounts.account_id FROM projects_accounts
INNER JOIN accounts ON accounts.id = projects_accounts.account_id AND accounts.deleted = 0
WHERE projects_accounts.deleted = 0 AND accounts.name LIKE \'%{0}%\'',
'db_field' =>
array (
0 => 'id',
),
),
If I put something wrong on purpose in the query it shows the error, so I’m quite sure the query is being executed correctly. The only message that I can see is:
[DEPRECATED] Using row number in fetchByAssoc is not portable and no longer supported. Please fix your code.
It always returns 0 results when you fill the field Account. Any ideas?
Thank you!!