Skip to content

Instantly share code, notes, and snippets.

@robert-michels
Last active March 23, 2021 02:02
Show Gist options
  • Select an option

  • Save robert-michels/c64698d770388ce87b755a84a700070e to your computer and use it in GitHub Desktop.

Select an option

Save robert-michels/c64698d770388ce87b755a84a700070e to your computer and use it in GitHub Desktop.
<?php
// CODE SNIPPET, NOT THE FULL FILE //
/**
* @return Omen
*/
public static function getOmenBySlug(string $slug) : Omen
{
//Select all from the table that is created by performing inner joins. Tables joined: omen, aspect, death & fault.
$query = "SELECT * FROM";
//Join omen with aspect
$query .= " (((".self::T_OMEN." INNER JOIN ".self::T_ASPECT." ON ".self::T_OMEN.".".self::C_ASPECT." = ".self::T_ASPECT.".".self::C_TERM.")";
//Join result with death
$query .= " INNER JOIN ".self::T_DEATH." ON ".self::T_OMEN.".".self::C_DEATH." = ".self::T_DEATH.".".self::C_TERM.")";
//Join result with fault
$query .= " INNER JOIN ".self::T_FAULT." ON ".self::T_OMEN.".".self::C_FAULT." = ".self::T_FAULT.".".self::C_TERM.")";
//Filter result by omen slug
$query .= " WHERE ".self::T_OMEN.".".self::C_SLUG." = '".$slug."';";
return (new self)->processQuery($query)->getOmens()[0];
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment