[Koha-devel] DBIx query or

Jonathan Druart jonathan.druart at bugs.koha-community.org
Tue Nov 3 11:30:17 CET 2020


Hi Frido,

On 26407 we must use an arrayref as we searched on the same attribute, but
otherwise both syntax are identical.

Koha::Patrons->search({ -or => { surname => 'koha', firstname => 'koha' } })
Koha::Patrons->search({ -or => [ surname => 'koha', firstname => 'koha' ] })
Koha::Patrons->search([ surname => 'koha', firstname => 'koha' ])
Will generate the same query.

Same for:
Koha::Patrons->search({ -and => { surname => 'koha', firstname => 'koha' }
})
Koha::Patrons->search({ -and => [ surname => 'koha', firstname => 'koha' ]
})
Koha::Patrons->search({ surname => 'koha', firstname => 'koha' })

See also https://metacpan.org/pod/SQL::Abstract::Classic#WHERE-CLAUSES

Cheers,
Jonathan


Le mar. 3 nov. 2020 à 09:02, Fridolin SOMERS <fridolin.somers at biblibre.com>
a écrit :

> Hi,
>
> I recently changed a call on Koha::Biblios->search() to use an arrayref
> instead of hashref :
> https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26407
>
> But I see there are both arrayref of hashref existing in code for "-or"
> query.
>
> What is the difference ?
> Is there a way we should choose in guidelines ?
>
> Best regards,
>
> --
> Fridolin SOMERS <fridolin.somers at biblibre.com>
> Software and system maintainer 🦄
> BibLibre, France
> _______________________________________________
> Koha-devel mailing list
> Koha-devel at lists.koha-community.org
> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : http://www.koha-community.org/
> git : http://git.koha-community.org/
> bugs : http://bugs.koha-community.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20201103/d4a2a585/attachment.htm>


More information about the Koha-devel mailing list