0
votes

I have a question regarding extbase if I need to inject a reposotory into another reposotry for getting join condition in the query what I need to do for that?

For example this query

     $query = $this->createQuery()
      ->statement('
           SELECT tx_casmarketing_domain_model_category.uid, tx_casmarketing_domain_model_category.name
           FROM tx_casmarketing_domain_model_category, tx_casmarketing_domain_model_ad
           WHERE tx_casmarketing_domain_model_ad.ad_cat = tx_casmarketing_domain_model_category.uid ')

This query I am trying to access through

  $query = $this->createQuery();
       $query->matching(
               );

Basically I am trying to inject one ad repository to category repository because there is no relationship defined in model for that.

my model contain category to ads relationship so when i access ads throughs adRepository I automcally accesss the cateogrys along with adCategory Repository, but in vise-virsa when i need category which has been selected for the ads i can only access through joining in query becus i do not have that relationship in my model. i need that category for my doropdown list in ads that how many ads category corrently ads contain...

this->adrepository->findAll() i automcally access ads with selected cateogry because this relationship already exist in my model but i need some how $this->categoryRepository($this->adrepository->finAll())

in drop down list i need only that category which is currently active. I can access this through simple query like i mention above but i need it through extbase query stuff becuse with extbase query way i can use buitin functionaly of typo3 like time stamp for start and end and hidden builtin functionality i want

  ->statement('
      SELECT tx_casmarketing_domain_model_category.uid,      tx_casmarketing_domain_model_category.name
          FROM tx_casmarketing_domain_model_category, tx_casmarketing_domain_model_ad
          WHERE tx_casmarketing_domain_model_ad.ad_cat = tx_casmarketing_domain_model_category.uid ')  this is working but i want to conver it thourgh extbase query
1

1 Answers

0
votes

To make it work with common repository methods you have to define the object-relations in TCA (and not sure if in model too). Then you can use functions like $query->equals('category',$category) or $query->contains('category',$category).

What is the purpose of your query? You are trying to find all categories that are are assigned by an "ad"?