Exemplo n.º 1
0
 /**
  * 
  * Modifies the native fetch with an eager join so that the foreign table
  * is joined properly.
  * 
  * @param Solar_Sql_Model_Params_Eager $eager The eager params.
  * 
  * @param Solar_Sql_Model_Params_Fetch $fetch The native fetch params.
  * 
  * @return void
  * 
  * @see modEagerFetch()
  * 
  */
 protected function _modEagerFetch($eager, $fetch)
 {
     $join = array('type' => $eager['join_type'], 'name' => "{$this->foreign_table} AS {$eager['alias']}", 'cond' => array(), 'cols' => null);
     // primary-key join condition on foreign table
     $join['cond'][] = "{$fetch['alias']}.{$this->native_col} = " . "{$eager['alias']}.{$this->foreign_col}";
     // foreign and eager conditions
     $join['cond'] = array_merge($join['cond'], $this->getForeignConditions($eager['alias']), (array) $eager['conditions']);
     // done!
     $fetch->join($join);
     // always DISTINCT so we don't get multiple duplicate native rows
     $fetch->distinct(true);
 }
Exemplo n.º 2
0
 /**
  * 
  * Modifies the native fetch with an eager join so that the foreign table
  * is joined properly.
  * 
  * @param Solar_Sql_Model_Params_Eager $eager The eager params.
  * 
  * @param Solar_Sql_Model_Params_Fetch $fetch The native fetch params.
  * 
  * @return void
  * 
  */
 protected function _modEagerFetchJoin($eager, $fetch)
 {
     $join = array('type' => $eager['join_type'], 'name' => "{$this->foreign_table} AS {$eager['alias']}", 'cond' => array(), 'cols' => null);
     // primary-key join condition on foreign table
     $join['cond'][] = "{$fetch['alias']}.{$this->native_col} = " . "{$eager['alias']}.{$this->foreign_col}";
     // extra conditions for the parent fetch
     if ($eager['join_cond']) {
         // what type of join?
         if ($join['type'] == 'left') {
             // convert the eager conditions to a WHERE clause
             foreach ((array) $eager['join_cond'] as $cond => $val) {
                 $fetch->where($cond, $val);
             }
         } else {
             // merge join conditions
             $join['cond'] = array_merge($join['cond'], (array) $eager['join_cond']);
         }
     }
     // done!
     $fetch->join($join);
     // always DISTINCT so we don't get multiple duplicate native rows
     $fetch->distinct(true);
 }
Exemplo n.º 3
0
 /**
  * 
  * Modifies the native fetch params with eager joins so that the through 
  * table and the foreign table are joined properly.
  * 
  * @param Solar_Sql_Model_Params_Eager $eager The eager params.
  * 
  * @param Solar_Sql_Model_Params_Fetch $fetch The native fetch params.
  * 
  * @return void
  * 
  * @see modEagerFetch()
  * 
  */
 protected function _modEagerFetch($eager, $fetch)
 {
     // first, join the native table to the through table
     $thru = array('type' => strtolower($this->through_join_type), 'name' => "{$this->through_table} AS {$this->through_alias}", 'cond' => array(), 'cols' => null);
     $thru['cond'][] = "{$fetch['alias']}.{$this->native_col} = " . "{$this->through_alias}.{$this->through_native_col}";
     $thru['cond'] = array_merge($thru['cond'], $this->through_conditions);
     // keep for countPages() calls?
     if ($thru['type'] != 'left') {
         $thru['keep'] = true;
     } else {
         $thru['keep'] = false;
     }
     $fetch->join($thru);
     // now join to the through table to the foreign table
     $join = array('type' => strtolower($eager['join_type']), 'name' => "{$this->foreign_table} AS {$eager['alias']}", 'cond' => array(), 'cols' => null);
     $join['cond'][] = "{$eager['alias']}.{$this->foreign_col} = " . "{$this->through_alias}.{$this->through_foreign_col}";
     // foreign and eager conditions
     $join['cond'] = array_merge($join['cond'], $this->getForeignConditions($eager['alias']), (array) $eager['conditions']);
     // keep for countPages() calls only if we kept "through", and the
     // foreign join is not a left join
     if ($thru['keep'] && $join['type'] != 'left') {
         $join['keep'] = true;
     } else {
         $join['keep'] = false;
     }
     // done!
     $fetch->join($join);
     // always DISTINCT so we don't get multiple duplicate native rows
     $fetch->distinct(true);
 }
 /**
  * 
  * Modifies the native fetch params with eager joins so that the through 
  * table and the foreign table are joined properly.
  * 
  * @param Solar_Sql_Model_Params_Eager $eager The eager params.
  * 
  * @param Solar_Sql_Model_Params_Fetch $fetch The native fetch params.
  * 
  * @return void
  * 
  * @see modEagerFetch()
  * 
  */
 protected function _modEagerFetch($eager, $fetch)
 {
     // first, join the native table to the through table
     $thru = array('type' => 'left', 'name' => "{$this->through_table} AS {$this->through_alias}", 'cond' => array(), 'cols' => null);
     $thru['cond'][] = "{$fetch['alias']}.{$this->native_col} = " . "{$this->through_alias}.{$this->through_native_col}";
     $thru['cond'] = array_merge($thru['cond'], $this->through_conditions);
     $fetch->join($thru);
     // now join to the through table to the foreign table
     $join = array('type' => $eager['join_type'], 'name' => "{$this->foreign_table} AS {$eager['alias']}", 'cond' => array(), 'cols' => null);
     $join['cond'][] = "{$eager['alias']}.{$this->foreign_col} = " . "{$this->through_alias}.{$this->through_foreign_col}";
     // foreign and eager conditions
     $join['cond'] = array_merge($join['cond'], $this->getForeignConditions($eager['alias']), (array) $eager['conditions']);
     // done!
     $fetch->join($join);
     // always DISTINCT so we don't get multiple duplicate native rows
     $fetch->distinct(true);
 }