protected function set_up($args) { $db = new Database($this->wpdb); $this->table = $db->getTable($args['table']); // Check that a point column exists. $points = $this->table->getColumns('point'); if (empty($points)) { // @TODO Show error. return; } $point_col = array_shift($points); $this->point_col_name = $point_col->getName(); // Apply filters. $filter_param = isset($args['filter']) ? $args['filter'] : array(); $this->table->addFilters($filter_param); $this->table->addFilter($this->point_col_name, 'not empty', ''); }
/** * 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; }