Function DatabaseConnector->singular_join

Definitions

sources/database.php

  • Generate a JOIN clause that will only bind to a single row.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: string

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$table string No No required parameter N/A N/A Table to join to
$alias string No No required parameter N/A N/A Alias for the table
$join_clause string No No required parameter N/A N/A The regular join clause
$threshold_field string No No id N/A N/A The field we will use to choose which row to match
$threshold_func string No No MIN N/A N/A The SQL function to apply to $threshold_field
$join_type string No No LEFT JOIN "LEFT JOIN" "JOIN" N/A The join type
$prefer_index ?string No No Null N/A N/A Index to force (null: none)

Returns

  • JOIN clause
  • Type: string
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Generate a JOIN clause that will only bind to a single row.
 *
 * @param  string $table Table to join to
 * @param  string $alias Alias for the table
 * @param  string $join_clause The regular join clause
 * @param  string $threshold_field The field we will use to choose which row to match
 * @param  string $threshold_func The SQL function to apply to $threshold_field
 * @param  string $join_type The join type
 * @set "LEFT JOIN" "JOIN"
 * @param  ?string $prefer_index Index to force (null: none)
 * @return string JOIN clause
 */

public function singular_join(string $table, string $alias, string $join_clause, string $threshold_field = 'id', string $threshold_func = 'MIN', string $join_type = 'LEFT JOIN', ?string $prefer_index = null) : string