• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Yoast SEO a2z

Yoast SEO a2z

WordPress SEO a2z

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / ORM::add_join_source() – Add a JOIN source to the query. Internal method.

You appear to be a bot. Output may be restricted

Description

Add a JOIN source to the query. Internal method.

The join_operator should be one of INNER, LEFT OUTER, CROSS etc – this will be prepended to JOIN. The table should be the name of the table to join to. The constraint may be either a string or an array with three elements. If it is a string, it will be compiled into the query as-is, with no escaping. The recommended way to supply the constraint is as an array with three elements: first_column, operator, second_column Example: array('user.id', '=', 'profile.user_id') will compile to ON user`.`id = profile`.`user_id The final (optional) argument specifies an alias for the joined table.

Usage

$ORM = ORM::add_join_source( $join_operator, $table, $constraint, $table_alias );

Parameters

$join_operator
( string ) required – The join_operator should be one of INNER, LEFT OUTER, CROSS etc – this will be prepended to JOIN.
$table
( string ) required – The table should be the name of the table to join to.
$constraint
( string ) required – The constraint.
$table_alias
( string|null ) optional – The alias for the joined table. Defaults to null.

Returns

ORM

Source

File name: wordpress-seo/lib/orm.php
Lines:

1 to 20 of 20
  protected function add_join_source( $join_operator, $table, $constraint, $table_alias = null ) {
    $join_operator = \trim( "{$join_operator} JOIN" );
    $table         = $this->quote_identifier( $table );
    // Add table alias if present.
    if ( ! \is_null( $table_alias ) ) {
      $table_alias = $this->quote_identifier( $table_alias );
      $table      .= " {$table_alias}";
    }
    // Build the constraint.
    if ( \is_array( $constraint ) ) {
      list( $first_column, $operator, $second_column ) = $constraint;

      $first_column  = $this->quote_identifier( $first_column );
      $second_column = $this->quote_identifier( $second_column );
      $constraint    = "{$first_column} {$operator} {$second_column}";
    }
    $this->join_sources[] = "{$join_operator} {$table} ON {$constraint}";

    return $this;
  }
 

 View on GitHub View on Trac

Published: 2nd September 2020 | Last updated: 10th December 2020

Primary Sidebar

Information

Function name: ORM::add_join_source
Class ref: ORM
Plugin ref: Yoast SEO
Version: 19.9
Sourcefile: lib/orm.php
File ref: lib/orm.php
Deprecated?: No
API Letters: A,J,O,S

Footer

Yoast SEO a2z
Yoast SEO a2z
WordPress SEO a2z
WordPress 6.1.1
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  wordpress-seo.wp-a2z.org
© Copyright Yoast SEO a2z 2017-2023. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites