/**
  * Get a set of results for Foreign Key lookups.
  * @param \WordPress\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->reset_filters();
     $table->add_filter($table->get_title_column(), $operator, $term);
     $out = array();
     foreach ($table->get_records() as $record) {
         $out[$record->get_primary_key()] = array('value' => $record->get_primary_key(), 'label' => $record->get_title());
     }
     return $out;
 }
Example #2
0
 /**
  * Get a list of records that reference this record in one of their columns.
  *
  * @param string|\WordPress\Tabulate\DB\Table $foreign_table
  * @param string|\WordPress\Tabulate\DB\Column $foreign_column
  * @param boolean $with_pagination Whether to only return the top N records.
  * @return \WordPress\Tabulate\DB\Record[]
  */
 public function get_referencing_records($foreign_table, $foreign_column, $with_pagination = true)
 {
     $foreign_table->reset_filters();
     $foreign_table->add_filter($foreign_column, '=', $this->get_primary_key(), true);
     return $foreign_table->get_records($with_pagination);
 }