コード例 #1
0
ファイル: Facade.class.php プロジェクト: evilgeny/bob
 /**
  * Returns query for holder report
  *
  * @return RM_Db_Query
  */
 public function getClassifyReportQuery()
 {
     $query = M('Db')->createQuery($this->_mapper->table('invoice_item') . ' AS ii');
     $query->join('ii', 'LEFT JOIN ' . $this->_mapper->table('invoice') . ' AS i ON ii.invoice_id = i.id');
     $query->join('i', 'LEFT JOIN ' . $this->_mapper->table('holder') . ' AS h1 ON i.from_holder_id = h1.id');
     $query->join('i', 'LEFT JOIN ' . $this->_mapper->table('holder') . ' AS h2 ON i.to_holder_id = h2.id');
     $query->what('i.number, ii.*');
     $aliases = array();
     $binds_1 = RM_Holder_Mapper::addPermissionToQuery($query, $aliases, 'h1');
     $binds_2 = RM_Holder_Mapper::addPermissionToQuery($query, $aliases, 'h2');
     $query->where('( ' . $aliases['h1_access_ri'] . ' = ? OR ' . $aliases['h2_access_ri'] . '= ? )', $binds_1['ri'][0], $binds_1['ri'][1], PERM_ALLOW, $binds_2['ri'][0], $binds_2['ri'][1], PERM_ALLOW);
     return $query;
 }