$this->db->select('*');
$this->db->from('test1');
$this->db->join('test2', 'test1.id = test2.test1_id');
$query = $this->db->get();
이렇게 하였을 때요..
function using($table, $cond, $type = '')
{
if ($type != '')
{
$type = strtoupper(trim($type));
if ( ! in_array($type, array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER')))
{
$type = '';
}
else
{
$type .= ' ';
}
}
// Extract any aliases that might exist. We use this information
// in the _protect_identifiers to know whether to add a table prefix
$this->_track_aliases($table);
$cond = $this->_protect_identifiers($cond);
// Assemble the JOIN statement
$join = $type.'JOIN '.$this->_protect_identifiers($table, TRUE, NULL, FALSE).' USING ('.$cond.')';
$this->ar_join[] = $join;
if ($this->ar_caching === TRUE)
{
$this->ar_cache_join[] = $join;
$this->ar_cache_exists[] = 'join';
}
return $this;
}
저는 join을 수정해서 추가사용했습니다. join할 이름이 같다면...
$this->db->using('테이블이름','동일필드이름','조인명');
$this->db->using('test1,'field','left');
일반 쿼리에서도 그렇게 쓸 방법이 없을겁니다.
$this->db->select('test1.name as name1, test2,name as name2');
이렇게 쓰시면 됩니다.