src/Query/Simple_Query.php
protected function get_by_or_many_by_helper( $column, $value, $columns = '*', $method ) {

		$builder = new Builder();

		$allowed_columns = $this->table->get_columns();

		if ( is_array( $columns ) ) {

			$select = new Select( null );

			foreach ( $columns as $col ) {

				if ( ! isset( $allowed_columns[ $col ] ) ) {
					throw new InvalidColumnException( "Invalid column." );
				}

				$select->also( "`$col`" );
			}
		} elseif ( $columns == Select::ALL ) {
			$select = new Select( $columns );
		} else {
			if ( ! isset( $allowed_columns[ $columns ] ) ) {
				throw new InvalidColumnException( "Invalid column" );
			}

			$select = new Select( "`$columns`" );
		}

		$builder->append( $select );
		$builder->append( new From( $this->table->get_table_name( $this->wpdb ) ) );
		$builder->append( new Where( "`$column`", true, $this->escape_value( $column, $value ) ) );

		return $this->wpdb->{$method}( trim( $builder->build() ) );
	}
protected function get_by_or_many_by_helper( $column, $value, $columns = '*', $method ) {

		$builder = new Builder();

		$allowed_columns = $this->table->get_columns();

		if ( is_array( $columns ) ) {

			$select = new Select( null );

			foreach ( $columns as $col ) {

				if ( ! isset( $allowed_columns[ $col ] ) ) {
					throw new InvalidColumnException( "Invalid column." );
				}

				$select->also( "`$col`" );
			}
		} elseif ( $columns == Select::ALL ) {
			$select = new Select( $columns );
		} else {
			if ( ! isset( $allowed_columns[ $columns ] ) ) {
				throw new InvalidColumnException( "Invalid column" );
			}

			$select = new Select( "`$columns`" );
		}

		$builder->append( $select );
		$builder->append( new From( $this->table->get_table_name( $this->wpdb ) ) );
		$builder->append( new Where( "`$column`", true, $this->escape_value( $column, $value ) ) );

		return $this->wpdb->{$method}( trim( $builder->build() ) );
	}
Helper function for get_by and get_many_by methods.

@param string $column
@param mixed  $value
@param string $columns
@param string $method

@return mixed
@throws InvalidColumnException