Jump to content

Table and join


Recommended Posts

$table->joins = array(
	array( 'select' => 'othertable.*', 'from' => array( 'myapp_othertable', 'othertable'), 'where' => "myapp_firsttable.id=othertable.other_id" )

How can I access to othertable fields on template row?

My table is generated with:

$table = new \IPS\Helpers\Table\Content...

but If I debug the object in template row I can't see "othertable" fields.


Link to comment
Share on other sites

You'll probably have to use Custom table.


use your content class in table Content and then join another table, like they do on members profile:

		$table = new \IPS\Helpers\Table\Content( $currentClass, $url, NULL, NULL, \IPS\Content\Hideable::FILTER_AUTOMATIC, 'read', FALSE );
		$table->joins = array(
				'select' => "core_reputation_index.id AS rep_id, core_reputation_index.rep_date, core_reputation_index.rep_rating, core_reputation_index.member_received as rep_member_received, core_reputation_index.member_id as rep_member, core_reputation_index.reaction as rep_reaction",
				'from'   => 'core_reputation_index',
				'where'  => array( "core_reputation_index.type_id=" . $currentClass::$databaseTable . "." . $currentClass::$databasePrefix . $currentClass::$databaseColumnId  . " AND ( core_reputation_index.member_id=? OR core_reputation_index.member_received=? ) AND core_reputation_index.app=? AND core_reputation_index.type=?", $this->member->member_id, $this->member->member_id, $currentClass::$application, $currentClass::reactionType() ),
				'type'   => 'INNER'

$currentClass would be your content item class.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...