Browse Source

Add the remaining join functions

Abdullah Almsaeed 6 năm trước cách đây
mục cha
commit
08367424ad
1 tập tin đã thay đổi với 92 bổ sung0 xóa
  1. 92 0
      tripal_chado/includes/ChadoPrefixExtender.inc

+ 92 - 0
tripal_chado/includes/ChadoPrefixExtender.inc

@@ -55,6 +55,29 @@ class ChadoPrefixExtender extends SelectQueryExtender {
     return $query->extend('ChadoPrefixExtender');
   }
 
+  /**
+   * @param $type
+   * @param $table
+   * @param null $alias
+   * @param null $condition
+   * @param array $arguments
+   *
+   * @return $this
+   *
+   * @see SelectQueryInterface::addJoin()
+   */
+  public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = []) {
+    $table = static::getTable($table);
+
+    if (is_null($alias)) {
+      $alias = static::makeAlias($table);
+    }
+
+    $this->query->addJoin($type, $table, $alias, $condition, $arguments);
+
+    return $this;
+  }
+
   /**
    * Overwrites the join to prefix table names.
    *
@@ -84,6 +107,75 @@ class ChadoPrefixExtender extends SelectQueryExtender {
     return $this;
   }
 
+  /**
+   * Overwrites the innerJoin to prefix table names.
+   *
+   * @param string $table
+   *   Table to join.
+   * @param string $alias
+   *   Alias for joined table.
+   * @param string $condition
+   *   Operation for joining.
+   * @param array $arguments
+   *   Additional arguments.
+   *
+   * @return $this
+   *   The current object.
+   *
+   * @ingroup tripal_chado_query_api
+   */
+  public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = []) {
+    $table = static::getTable($table);
+
+    if (is_null($alias)) {
+      $alias = static::makeAlias($table);
+    }
+
+    $this->query->innerJoin($table, $alias, $condition, $arguments);
+
+    return $this;
+  }
+
+  public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = []) {
+    $table = static::getTable($table);
+
+    if (is_null($alias)) {
+      $alias = static::makeAlias($table);
+    }
+
+    $this->query->leftJoin($table, $alias, $condition, $arguments);
+
+    return $this;
+  }
+
+  /**
+   * Overwrites the rightJoin to prefix table names.
+   *
+   * @param string $table
+   *   Table to join.
+   * @param string $alias
+   *   Alias for joined table.
+   * @param string $condition
+   *   Operation for joining.
+   * @param array $arguments
+   *   Additional arguments.
+   *
+   * @return $this
+   *   The current object.
+   *
+   * @ingroup tripal_chado_query_api
+   */
+  public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = []) {
+    $table = static::getTable($table);
+
+    if (is_null($alias)) {
+      $alias = static::makeAlias($table);
+    }
+
+    $this->query->rightJoin($table, $alias, $condition, $arguments);
+
+    return $this;
+  }
 
   /**
    * Checks if a table is a chado table.