Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Update: Added code to generate the params.

Hmm - that might be pretty hard (I assume that you want an article that is linked to all of the tags in @with instead of the castaway's interpretation). Here are some loose thoughts.

Lets take a bit simplified case where the @with contains the articlelinks ids and not think about the @without part at all. Than you need a query like:

SELECT * FROM article, articlelinks, articlelinks articlelinks_2, articlelinks artic +lelinks_3 ... WHERE = articlelinks.article AND = $with[0] AND = articlelinks_1.article AND = $with[1] A +ND ...
To produce this with DBIC you need something like:
my %params; $params{''} = $with[0]; for my $i ( 2 .. (scalar @with) - 1 ){ $params{"articlelinks_$"} = $with[$i - 1]; } my @articles = $schema->resultset('articles')->search( \%params, { join => [ 'articlelinks' x scalar( @with ) ] } );
The @without part is a bit simpler, thanks to De Morgan lows. But how to compose those two parts? In raw SQL I would use 'EXCEPT' but in DBIC? And how to go from the list of 'articlelinks' ids to tags?

More questions than answers here - but I've heard mst was looking for hard cases so perhaps some day he shall simplify that? I'm interested - as I use a similar structure in my bookmarking app.

In reply to Re: DBIx::Class and many-to-many searching by zby
in thread DBIx::Class and many-to-many searching by BrentDax

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-06-21 11:45 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.