/** * Get a list of records that reference this record in one of their columns. * * @param string|\Tabulate\DB\Table $foreignTable * @param string|\Tabulate\DB\Column $foreignColumn * @param boolean $withPagination Whether to only return the top N records. * @return \Tabulate\DB\Record[] */ public function getReferencingRecords($foreignTable, $foreignColumn, $withPagination = true) { $foreignTable->resetFilters(); $foreignTable->addFilter($foreignColumn, '=', $this->getPrimaryKey(), true); return $foreignTable->getRecords($withPagination); }
/** * Get a set of results for Foreign Key lookups. * @param \Tabulate\DB\Table $table The table to search. * @param string $operator One of the permitted filter operators. * @param string $term The search term. * @return string[] */ protected function foreign_key_values_build($table, $operator, $term) { $table->resetFilters(); $table->addFilter($table->getTitleColumn(), $operator, $term); $out = array(); foreach ($table->getRecords() as $record) { $out[$record->getPrimaryKey()] = array('value' => $record->getPrimaryKey(), 'label' => $record->getTitle()); } return $out; }