2017-01-30 126 views
0

我有一个关于extbase的问题,如果我需要注入一个reposotory到另一个获取连接条件的查询中获取连接条件,我需要为此做些什么?extbase查询生成器注入一个存储库到另一个存储库

例如这个查询

 $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 ') 

该查询我试图通过

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

基本上我试图注入一个广告资源库类别访问资源库中,因为没有在模型中定义的关系为了那个原因。

我的模型包含类别与广告的关系,所以当我通过adrepository访问广告时我自动访问cateogrys和adCategory Repository,但是在vise-virsa中,当我需要类别时,我只能通过连接访问广告在查询因为我没有在我的模型中的关系。我需要该类别的广告中,我的广告多少广告类别正当广告包含...

this-> adrepository-> findAll()我自动访问广告与选定的cateogry,因为这种关系已经存在于我的模型,但我需要一些$ this-> categoryRepository($ this-> adrepository-> finAll())

在下拉列表中,我只需要那个当前活动的类别。我可以通过简单的查询访问此正如我前面提到,但我需要它通过extbase查询的东西becuse与extbase查询方式,我可以使用buitin像开始和结束的时间标记TYPO3的functionaly和隐藏的内置功能,我想

->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 

回答

0

为了使它与常用的存储库方法一起工作,您必须在TCA中定义对象关系(并且不确定是否也在模型中)。然后你可以使用像$ query-> equals('category',$ category)或$ query-> contains('category',$ category)这样的函数。

查询的目的是什么?您正在尝试查找由“广告”分配的所有类别?

+0

感谢您的答复保罗。我在上面的描述中进一步解释我的问题。你可以检查它可能会帮助你更好地理解我的问题。 – zahid

相关问题