Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

inner join not rendering data

Go to End


Optic Blaze

Community Member, 190 Posts

3 March 2016 at 2:34am

Edited: 03/03/2016 2:38am

Hi there, I have 2 x objects. Player & Team and a page type called PlayerStatsPage where I want to show the scorers stats of each player. Included in the stats I want the team name. I cant seem to get the team name to render in my template. Please help

 class Player extends DataObject {
static $db = array(
	'DateJoined'=> 'Date',
	private static $has_one = array(
    'TeamJoin' => 'Team',

	// Build database coliumns
	static $db = array(
	// Set up relationships
	private static $has_many = array(
    'PlayerJoin' => 'Player',

class PlayerStatsPage_Controller extends Page_Controller {

	private static $allowed_actions = array (

	public function init(){
	// Function that creates player stats
	function playerstats() {	

	$players = Player::get()
	->innerJoin("Team", "\"Player\".\"TeamJoinID\" = \"Team\".\"ID\"")
    'DateJoined:StartsWith' => $this->Year
		$playerlist = new ArrayList();
		foreach($players as $item) {
		//Declare variables and do calculations on them
		$playername = $item->PlayerName;
		$team = $item->TeamJoin[TeamName];
		$tries = $item->Tries;
		$conversions = $item->Conversions;
		$penalties = $item->Penalties;
		$dropgoals = $item->DropGoals;
		//Build new array with calculated data
			new ArrayData(array(
			'Player' => $playername,
			'Team' => $team,
			'Tries' => $tries,
			'Conversions' => $conversions,
			'Penalties' => $penalties ,
			'DropGoal' =>$dropgoals ,
			'Total' => ($tries*5)+($conversions*2)+($penalties*3)+($dropgoals*3)
		return $playerlist;

As you can see, i want to pull the team name data into the custom array, but when i try and render the data on my .ss template, nothing shows. Am i doing the join incorrectly or should i be doing something else.