public function getBelongsToReference($table, $key) { $tableColumns = $this->structure->getBelongsToReference($table); foreach ($tableColumns as $column => $targetTable) { if (stripos($column, $key) !== FALSE) { return array($targetTable, $column); } } if ($this->structure->isRebuilt()) { return NULL; } $this->structure->rebuild(); return $this->getBelongsToReference($table, $key); }
public function getBelongsToReference($table, $key) { $tableColumns = $this->structure->getBelongsToReference($table); foreach ($tableColumns as $column => $targetTable) { if (stripos($column, $key) !== FALSE || stripos($targetTable, $key) !== FALSE) { //also check if any reference exists return [$targetTable, $column]; } } if ($this->structure->isRebuilt()) { return NULL; } $this->structure->rebuild(); return $this->getBelongsToReference($table, $key); }