| 제목 | [AR] get_where , _cache 사용시 주의점 | ||
|---|---|---|---|
| 글쓴이 | 마냐 | 작성시각 | 2009/08/05 17:24:03 |
|
|
|||
$this->db->get_where('table', array(
'fld1' => 'val1',
'fld2' => 'val2'
));
// result
select * from table where fld1 = 'val1' and fld2 = 'val2;
$this->db->where('fld2', 'val2');
$this->db->get_where('table', array(
'fld1' => 'val1'
));
// result
select * from table where fld2 = 'val2' and fld1 = 'val1';
$this->db->start_cache();
$this->db->where('fld2', 'val2');
$this->db->stop_cache();
$this->db->get_where('table', array(
'fld1' => 'val1'
));
$this->db->flush_cache();
// result
select * from table where fld2 = 'val2' and fld1 = 'val1';
get_where 에서는 두번째 파라미터로 where 을 사용 할 수 있는데.이 두번째 파라미터로 넘겨주는 where 값은 where 의 맨 마지막에 연결 됨. 또, $this->db->start_cache(); 로 저장하는 값은 맨 앞에 연결 됨.
$this->db->where('bo_table', 'test');
$this->db->start_cache();
$this->db->where('wr_id', '10');
$this->db->stop_cache();
$this->db->get_where('table', array(
'is_comment' => 1
));
$this->db->flush_cache();
// result
select * from table where and wr_id = '10' bo_table = 'test' and is_comment = 1;
구분 오류를 발생.---- DB index 순서에 주의. |
|||
| 다음글 | CI 클래스, 헬퍼, 플러그인 개념비교 (4) | ||
| 이전글 | 이클립스 php 사용팁 (7) | ||
|
ci세상
/
2009/08/05 17:43:38 /
추천
0
네넹 코딩시 참조하겠습니다.^^
|
|
변종원(웅파)
/
2009/08/05 18:14:30 /
추천
0
mysql은 where절의 순서에 상관이 없지 않은가요? where a=1 and b=2 간혹 쿼리 날리다보면 순차적으로 검색을 하기를 원하는데 mysql은 where절의 순서에 상관없이 |
|
터프키드
/
2009/08/05 18:14:52 /
추천
0
와~ 좋은팁 감사합니다~
|