Example #1
0
 /**
  * Create a new ManyManyList object.
  *
  * A ManyManyList object represents a list of {@link DataObject} records
  * that correspond to a many-many relationship.
  *
  * Generation of the appropriate record set is left up to the caller, using
  * the normal {@link DataList} methods. Addition arguments are used to
  * support {@@link add()} and {@link remove()} methods.
  *
  * @param string $dataClass The class of the DataObjects that this will list.
  * @param string $joinTable The name of the table whose entries define the content of this many_many relation.
  * @param string $localKey The key in the join table that maps to the dataClass' PK.
  * @param string $foreignKey The key in the join table that maps to joined class' PK.
  * @param string $extraFields A map of field => fieldtype of extra fields on the join table.
  *
  * @example new ManyManyList('Group','Group_Members', 'GroupID', 'MemberID');
  */
 public function __construct($dataClass, $joinTable, $localKey, $foreignKey, $extraFields = array())
 {
     parent::__construct($dataClass);
     $this->joinTable = $joinTable;
     $this->localKey = $localKey;
     $this->foreignKey = $foreignKey;
     $this->extraFields = $extraFields;
     $this->linkJoinTable();
 }
Example #2
0
 /**
  * Create a new ManyManyList object.
  * 
  * A ManyManyList object represents a list of DataObject records that correspond to a many-many
  * relationship.  In addition to, 
  * 
  * Generation of the appropriate record set is left up to the caller, using the normal
  * {@link DataList} methods.  Addition arguments are used to support {@@link add()}
  * and {@link remove()} methods.
  * 
  * @param string $dataClass The class of the DataObjects that this will list.
  * @param string $joinTable The name of the table whose entries define the content of this many_many relation.
  * @param string $localKey The key in the join table that maps to the dataClass' PK.
  * @param string $foreignKey The key in the join table that maps to joined class' PK.
  * @param string $extraFields A map of field => fieldtype of extra fields on the join table.
  * 
  * @example new ManyManyList('Group','Group_Members', 'GroupID', 'MemberID');
  */
 public function __construct($dataClass, $joinTable, $localKey, $foreignKey, $extraFields = array())
 {
     parent::__construct($dataClass);
     $this->joinTable = $joinTable;
     $this->localKey = $localKey;
     $this->foreignKey = $foreignKey;
     $this->extraFields = $extraFields;
     $baseClass = ClassInfo::baseDataClass($dataClass);
     // Join to the many-many join table
     $this->dataQuery->innerJoin($joinTable, "\"{$joinTable}\".\"{$this->localKey}\" = \"{$baseClass}\".\"ID\"");
     // Query the extra fields from the join table
     if ($extraFields) {
         $this->dataQuery->selectFromTable($joinTable, array_keys($extraFields));
     }
 }
 /**
  * Create a new ManyManyList object.
  * 
  * A ManyManyList object represents a list of {@link DataObject} records
  * that correspond to a many-many relationship.
  * 
  * Generation of the appropriate record set is left up to the caller, using
  * the normal {@link DataList} methods. Addition arguments are used to
  * support {@@link add()} and {@link remove()} methods.
  * 
  * @param string $dataClass The class of the DataObjects that this will list.
  * @param string $joinTable The name of the table whose entries define the content of this many_many relation.
  * @param string $localKey The key in the join table that maps to the dataClass' PK.
  * @param string $foreignKey The key in the join table that maps to joined class' PK.
  * @param string $extraFields A map of field => fieldtype of extra fields on the join table.
  * 
  * @example new ManyManyList('Group','Group_Members', 'GroupID', 'MemberID');
  */
 public function __construct($dataClass, $joinTable, $localKey, $foreignKey, $extraFields = array())
 {
     parent::__construct($dataClass);
     $this->joinTable = $joinTable;
     $this->localKey = $localKey;
     $this->foreignKey = $foreignKey;
     $this->extraFields = $extraFields;
     $baseClass = ClassInfo::baseDataClass($dataClass);
     // Join to the many-many join table
     $this->dataQuery->innerJoin($joinTable, "\"{$joinTable}\".\"{$this->localKey}\" = \"{$baseClass}\".\"ID\"");
     // Add the extra fields to the query
     if ($this->extraFields) {
         $this->appendExtraFieldsToQuery();
     }
 }
 /**
  * Create a new HasManyList object.
  * Generation of the appropriate record set is left up to the caller, using the normal
  * {@link DataList} methods.  Addition arguments are used to support {@@link add()}
  * and {@link remove()} methods.
  *
  * @param string $dataClass The class of the DataObjects that this will list.
  * @param string $foreignKey The name of the foreign key field to set the ID filter against.
  */
 public function __construct($dataClass, $foreignKey)
 {
     parent::__construct($dataClass);
     $this->foreignKey = $foreignKey;
 }