original_string: protected function getIdFor($strType, $strNameAbbr)
  	{
  		// Validate input
  		if (!in_array($strType, ['book', 'translation', 'topic']))
  			throw new Exception('Invalid entity type "' . $strType . '"');
  
  		// Query the db to get the ID
  		$strTableName = 'sudo_bible_' . $strType . 's';
  		$q = 'SELECT `id` FROM `' . $strTableName . '` WHERE `name` LIKE ?';
  		$aParams = [$strNameAbbr];
  		if ('topic' !== $strType) {
  			$q .= ' OR `abbr` LIKE ?';
  			$aParams[] = $strNameAbbr;
  		}
  		$aResult = $this->runPreparedQuery($q, $aParams);
  		$iId = $aResult[0]->id;
  
  		// Validate result
  		if (!is_numeric($iId))
  			throw new Exception('Invalid ' . $strType . ' "' .  $strNameAbbr . '" given.');
  
  		return $iId;
  	}
code: protected function getIdFor($strType, $strNameAbbr)
  	{
  		// Validate input
  		if (!in_array($strType, ['book', 'translation', 'topic']))
  			throw new Exception('Invalid entity type "' . $strType . '"');
  
  		// Query the db to get the ID
  		$strTableName = 'sudo_bible_' . $strType . 's';
  		$q = 'SELECT `id` FROM `' . $strTableName . '` WHERE `name` LIKE ?';
  		$aParams = [$strNameAbbr];
  		if ('topic' !== $strType) {
  			$q .= ' OR `abbr` LIKE ?';
  			$aParams[] = $strNameAbbr;
  		}
  		$aResult = $this->runPreparedQuery($q, $aParams);
  		$iId = $aResult[0]->id;
  
  		// Validate result
  		if (!is_numeric($iId))
  			throw new Exception('Invalid ' . $strType . ' "' .  $strNameAbbr . '" given.');
  
  		return $iId;
  	}
code_tokens: protected function getIdFor ( $ strType , $ strNameAbbr ) { // Validate input if ( ! in_array ( $ strType , [ 'book' , 'translation' , 'topic' ] ) ) throw new Exception ( 'Invalid entity type "' . $ strType . '"' ) ; // Query the db to get the ID $ strTableName = 'sudo_bible_' . $ strType . 's' ; $ q = 'SELECT `id` FROM `' . $ strTableName . '` WHERE `name` LIKE ?' ; $ aParams = [ $ strNameAbbr ] ; if ( 'topic' !== $ strType ) { $ q .= ' OR `abbr` LIKE ?' ; $ aParams [ ] = $ strNameAbbr ; } $ aResult = $ this -> runPreparedQuery ( $ q , $ aParams ) ; $ iId = $ aResult [ 0 ] -> id ; // Validate result if ( ! is_numeric ( $ iId ) ) throw new Exception ( 'Invalid ' . $ strType . ' "' . $ strNameAbbr . '" given.' ) ; return $ iId ; }
docstring: Get an ID, given the name.
  
  For now, we're using this instead of a JOIN in the main query
  so we can throw a useful error.
  
  @param string $strType translation, book, or topic
  @param string $strNameAbbr Name of the translation or book.
  @throws Exception
  @return int
docstring_tokens: Get an ID given the name .