title: Retrieving data from database and passing it as instance of entity
body: <p>I'm trying to pass id from query from one database table to another table to which is related.<br>
  But, since they are related I have to pass it as instance of the entity(class) to which is related.<br>
  This is error I got:  </p>
  
  <blockquote>
    <p>Argument 1 passed to App\Entity\KeywordRating::setKeywordId() must be an instance of App\Entity\Keywords, integer given, called in C:\xampp\htdocs\ratingAPI\src\Service\KeywordRatingService.php on line 26</p>
  </blockquote>
  
  <p>This is my code:</p>
  
  <pre><code>public function insertRating($params, ObjectManager $manager, KeywordsRepository $keyRep, ProvidersRepository $provRep)
  {
      $keywordId = $keyRep-&gt;checkKeyword(strtolower($params['keyword']))-&gt;getId();
      $providerId = $provRep-&gt;checkProvider($params['provider'])-&gt;getId();
  
      $rating = new KeywordRating();
      $rating-&gt;setKeywordId(&lt;Keywords instance&gt; $keywordId);
      $rating-&gt;setProviderId(&lt;Providers instance&gt; $providerId);
      if($params['attr'] === 'rocks')
      {
          $rating-&gt;setRocksRating($params['rating']);
          $rating-&gt;setSucksRating(0);
      } else 
      {
          $rating-&gt;setRocksRating(0);
          $rating-&gt;setSucksRating($params['rating']);
      }
      $rating-&gt;setRocksVotes(10);
      $rating-&gt;setSucksVotes(8);
      $rating-&gt;setSumVotes(18);
      $rating-&gt;setScore(2.50);
  
      $manager-&gt;persist($rating);
      $manager-&gt;flush();
  }
  </code></pre>
  
  <p>This is sql query:</p>
  
  <pre><code>public function checkKeyword($keyword)
  {
      return $this-&gt;createQueryBuilder('k')
          -&gt;where('k.keyword_name = :val')
          -&gt;setParameter('val', $keyword)
          -&gt;getQuery()
          -&gt;getOneOrNullResult();
  }
  </code></pre>
  
  <p>checkProvider() is the same, only different parameters.</p>
  
  <p>How do I do that?</p>