src/SudoBible.php
public function topic($mTopic, $bRandomOne = false)
	{
		// Sanitize input
		if (is_string($mTopic))
			$mTopic = $this->getIdFor('topic', $mTopic);

		// Search
		$q = 'SELECT tv.*, verses.`text`, books.`name` AS book_name, books.`abbr` AS book_abbr, books.`ot`, books.`nt`'
			. ' FROM `sudo_bible_topic_verses` AS tv'
			. ' LEFT JOIN `sudo_bible_verses` AS verses ON verses.`book_id` = tv.`book_id`'
				. ' AND verses.`chapter` = tv.`chapter` AND verses.`verse` = tv.`verse`'
			. ' LEFT JOIN `sudo_bible_books` AS books ON books.`id` = tv.`book_id`'
			. ' WHERE verses.`translation_id` = ? AND tv.`topic_id` = ?'
			. ' ORDER BY `book_id`, `chapter`, `verse`';
		$mResult = $this->runPreparedQuery($q, [$this->iTranslation, $mTopic]);

		// If a random passage was requested, pick one
		if ($bRandomOne) {
			$mResult = new SudoBiblePassage([$mResult[array_rand($mResult)]], $this);
		// Otherwise, convert all from stdClass to SudoBiblePassage
		} else {
			foreach ($mResult as $k => $oResult)
				$mResult[$k] = new SudoBiblePassage([$oResult], $this);
		}

		return $mResult;
	}
public function topic($mTopic, $bRandomOne = false)
	{
		// Sanitize input
		if (is_string($mTopic))
			$mTopic = $this->getIdFor('topic', $mTopic);

		// Search
		$q = 'SELECT tv.*, verses.`text`, books.`name` AS book_name, books.`abbr` AS book_abbr, books.`ot`, books.`nt`'
			. ' FROM `sudo_bible_topic_verses` AS tv'
			. ' LEFT JOIN `sudo_bible_verses` AS verses ON verses.`book_id` = tv.`book_id`'
				. ' AND verses.`chapter` = tv.`chapter` AND verses.`verse` = tv.`verse`'
			. ' LEFT JOIN `sudo_bible_books` AS books ON books.`id` = tv.`book_id`'
			. ' WHERE verses.`translation_id` = ? AND tv.`topic_id` = ?'
			. ' ORDER BY `book_id`, `chapter`, `verse`';
		$mResult = $this->runPreparedQuery($q, [$this->iTranslation, $mTopic]);

		// If a random passage was requested, pick one
		if ($bRandomOne) {
			$mResult = new SudoBiblePassage([$mResult[array_rand($mResult)]], $this);
		// Otherwise, convert all from stdClass to SudoBiblePassage
		} else {
			foreach ($mResult as $k => $oResult)
				$mResult[$k] = new SudoBiblePassage([$oResult], $this);
		}

		return $mResult;
	}
public function topic ( $ mTopic , $ bRandomOne = false ) { // Sanitize input if ( is_string ( $ mTopic ) ) $ mTopic = $ this -> getIdFor ( 'topic' , $ mTopic ) ; // Search $ q = 'SELECT tv.*, verses.`text`, books.`name` AS book_name, books.`abbr` AS book_abbr, books.`ot`, books.`nt`' . ' FROM `sudo_bible_topic_verses` AS tv' . ' LEFT JOIN `sudo_bible_verses` AS verses ON verses.`book_id` = tv.`book_id`' . ' AND verses.`chapter` = tv.`chapter` AND verses.`verse` = tv.`verse`' . ' LEFT JOIN `sudo_bible_books` AS books ON books.`id` = tv.`book_id`' . ' WHERE verses.`translation_id` = ? AND tv.`topic_id` = ?' . ' ORDER BY `book_id`, `chapter`, `verse`' ; $ mResult = $ this -> runPreparedQuery ( $ q , [ $ this -> iTranslation , $ mTopic ] ) ; // If a random passage was requested, pick one if ( $ bRandomOne ) { $ mResult = new SudoBiblePassage ( [ $ mResult [ array_rand ( $ mResult ) ] ] , $ this ) ; // Otherwise, convert all from stdClass to SudoBiblePassage } else { foreach ( $ mResult as $ k => $ oResult ) $ mResult [ $ k ] = new SudoBiblePassage ( [ $ oResult ] , $ this ) ; } return $ mResult ; }
Return all verses on a single topic.

@param int|string $mTopic The topic ID or name.
@param bool $bRandomOne Pick a random passage?
@return array|SudoBiblePassage
Return all verses on a single topic .