Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8544147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:29:02+00:00 2026-06-11T12:29:02+00:00

This is something that really bugs me, but first the code, then the question:

  • 0

This is something that really bugs me, but first the code, then the question:

<?php
 public static function retrievePagerByTagArray($page, $limit, $tags) {

    $criteria = new Criteria();

    $criteria->addJoin(self::MASTER_ID, MasterPeer::MASTER_ID);

    foreach($tags as $tag) {
      $criteria->addOr(MasterHasTagPeer::TAG_ID, $tag->getPrimaryKey());
    }

    $criteria->add(self::IS_ACTIVE, 1);
    $criteria->addDescendingOrderByColumn(self::MASTER_ID);
    $pager = new sfPropelPager('Master');

    $pager->setCriteria($criteria);
    $pager->setPage($page);
    $pager->setMaxPerPage($limit);
    $pager->init();
    return $pager;
  }

What i want to do is this:

my tags are made with get parameters so tags come like http://example.com?filter=tag1%7tag2 etc… i convert those tags to their corresponding tagid and want to filter my results to just the stuff that has those too parameters meaning:

master_has_tag is an n:m-table only storing the ids.

I know that the $criteria->addOr(MasterHasTagPeer::TAG_ID, $tag->getPrimaryKey()); is not what im looking for since this is giving me all entries containing atleast one of the filters

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:29:04+00:00Added an answer on June 11, 2026 at 12:29 pm

    It sounds like you want to build a query with WHERE tag_id IN (1, 2, 3, 4...). However, I’m not familiar with Symony or Propel so you will need to find the corresponding method.

    If $tags is an array of ids you can use implode() to combine the ids into a comma-separated string.

    $tag_ids = implode(',', $tags);
    

    If $tags is an array of objects then you can use array_map() to make the same thing.

    // create an array of tag ids
    $tags = array_map(function($tag) {
      return $tag->getPrimaryKey();
    }, $tags);
    
    // create a comma-separated string of ids
    $tag_ids = implode(',', $tags);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hope to get some help here because this is something that really makes me
This is a small doubt and something that shouldn't really come to one's mind.So
This is something that's been bugging me with PHP for a while now and
This is something that I solved using reflection, but would like to see how
this is something that i don't want to program, but i was looking for
This is something that I'm sure I should know the answer to, but either
today I ran into this problem which really bugs me, as almost the code
This is something that's been bugging me for many years: why most online services
This is something that's I've wanted to know recently, mostly out of curiousity. I'm
This is something that I don't see much discussed. I'm developing a software that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.