Composite Create Method

The composite_create method purpose is for generating key pair array for a parameter value in join_composite method.

Basic Usage

Here is the basic usage composite_create method from $db property on SENE_Model class.

$this->db->composite_create(string $table1_COLUMN_1, string $OPERATOR, string $table2_COLUMN_1): compositeObject;

Parameters

composite_create method has 3 required parameters and will returned join composite object

$table1_COLUMN_1

Column name for first table.

$OPERATOR

Can contain a relational operator, such as:

  • =
  • <>

$table2_COLUMN_1

Column name for second table.

This method available from Seme Framework version >= 3.2.1

Examples

Here is the example usage for using composite_create method.

class D_Sales_Model extends SENE_Model{
  public $table = 'd_sales';
  public $table_alias = 'dsl';
  public $table2 = 'b_seller';
  public $table2_alias = 'bs';

  public function __construct(){
    parent::__construct();
    $this->db->from($this->table,$this->table_alias);
  }
  private function __jointable2(){
    $composites = array();
    $composites[] = $this->db->composite_create("$this->table_alias.nation_code","=","$this->table_alias.nation_code");
    $composites[] = $this->db->composite_create("$this->table_alias.b_seller_id","=","$this->table_alias.id");
    return $composites;
  }
  public function getByOrderId($id){
    $this->db->join_composite($this->table2,$this->table2_alias,$this->__jointable2(),"inner");
    $this->db->where_as("$this->table_alias.id",$this->db->esc($id));
    return $this->db->get_first();
  }
}