XF 2.1 Using with() returns no data

Cupara

Well-known member
1. If I use with() on any of my fetches, it returns no data but if I remove it, then all data appears but won't display everything.
2. Another issue is that it only return the number of entries that are present in the smallest table so say I have 200k entries to grab but in one table I'm joining with, there is only 9 entries, then all I get is 9 entries of my 200k returned.
3. I'm not sure how to make a drop down list or filter results on the public pages to sort by a specific League or Sport.

Here is my controller:
PHP:
<?php
namespace BetClever\Tipsters\Pub\Controller;

class Tips extends \XF\Pub\Controller\AbstractController
{
    public function actionIndex()
    {
        $options = \XF::options();
        $db = \XF::db();
        $visitor = \XF::visitor();
        $app = \XF::app();
        $finder = \XF::finder('BetClever\Tipsters:Tips');
        $sportsFinder = \XF::finder('BetClever\Tipsters:Sports');
        $leaguesFinder = \XF::finder('BetClever\Tipsters:Leagues');
        $sportsByFinder = \XF::finder('BetClever\Tipsters:Tips');
        
        $sports = $sportsFinder->fetch();
        $leagues = $leaguesFinder->with('Sports', 'Countries')->fetch();
        $tips = $finder->with('Sports', 'Leagues', 'User')->where('status', 2)->fetch();
        
        $page = $this->filterPage();
        $perPage = 10;

        $finder->limitByPage($page, $perPage);

        $filter = $this->filter('_xfFilter', [
            'text' => 'str',
            'prefix' => 'bool'
        ]);
        
        if (strlen($filter['text']))
        {
            $finder->where('choice_name', 'LIKE', $finder->escapeLike($filter['text'], $filter['prefix'] ? '?%' : '%?%'));
        }

        $total = $finder->total();
        
        $viewParams = [
            'tips' => $tips,
            'sports' => $sports,
            'leagues' => $leagues,
            'total' => $total,
            'page' => $page,
            'perPage' => $perPage,
            'filter' => $filter['text']
        ];

        return $this->view('BetClever\Tipsters:View', 'bc_tips_view', $viewParams);
    }
    
    public function actionBySport($id)
    {
        $options = \XF::options();
        $db = \XF::db();
        $visitor = \XF::visitor();
        $app = \XF::app();
        $finder = \XF::finder('BetClever\Tipsters:Tips');
        $leaguesFinder = \XF::finder('BetClever\Tipsters:Leagues');
        $sportsFinder = \XF::finder('BetClever\Tipsters:Sports');
        
        $sport = $finder->where('sport_id', $id)->with('Sports')->fetch();
        $leagues = $leaguesFinder->with('Sports', 'Countries')->fetch();
        $tips = $finder->with('Sports', 'Leagues', 'Bets', 'User', 'Events')->fetch();
        
        $viewParams = [
            'sport' => $sport
        ];
        
        return $this->view('BetClever\Tipsters:View', 'bc_tips_view', $viewParams);
    }
    
    public function actionAdd()
    {
        
    }
}
 
This has been resolved, I discovered one of my columns in an entity was misspelled, once I fixed that everything worked.
 
Back
Top Bottom