| 제목 | get_table_query의 Where절에서 조인하는 방법? | ||
|---|---|---|---|
| 카테고리 | CIBOARD | ||
| 글쓴이 | 아리아리 | 작성시각 | 2018/07/12 11:05:26 |
|
|
|||
|
코드이그나이터에서 기본적으로 생성하는 Common_model에서 get_table_query() 함수를 통해 조인을 하고 싶습니다 그런데 문제가 Select * From TA a, TB b Where a.id = b.id 를 해야하는데 Select * From TA a, TB b Where a.id = 'b.id' Where 절 세팅을 하게되면 이렇게 인식을 하게됩니다 그래서 조인을 제대로 하지 못하는 상황입니다. 리터럴 그대로 quote 없이 저 질의를 실행할수 있게 하는 방법이 있을까요?
get_table_query 함수입니다
function get_table_query($table, $selectTxt = null, $whereTxt = null, $orderTxt = null, $limit = null, $whereAdd = null)
{
$selectSync = '';
if ($selectTxt) {
$selectSync = $selectTxt;
} else {
$selectSync = "*";
}
$whereSync = '';
if ($whereTxt) {
$whereSync = get_where_syntex($whereTxt);
}
$limitSync = '';
if ($limit) {
$limitSync = "Limit " . $limit[0] . "," . $limit[1];
}
$orderSync = '';
if ($orderTxt) {
$orderSync = "Order by " . $orderTxt[0] . ' ' . $orderTxt[1];
}
$query = "SELECT " . $selectSync . " FROM " . $table . ' ' . $whereSync . ' ' . $whereAdd . ' ' . $orderSync . ' ' . $limitSync;
//echo $query;
$rst = $this->db->query($query);
return $rst->result_array();
}
Select 절은 * FROM 절은 TA a, TB b Where 절 세팅은
$where_Array = Array(
'a.id' => Array('b.id', '='),
);
방법을 알려주세요 혹시 이스케이프를 요기서 사용하는건가요?
제가알기론 이스케이프는 그냥 string 에 quote 를 해주는걸로 알고 있습니다.
|
|||
| 다음글 | 에러발생 시 오류 표기 관련 질문드립니다 (2) | ||
| 이전글 | CI4는 view directory 지정할 수 없나요? (4) | ||
|
한대승(불의회상)
/
2018/07/12 14:02:06 /
추천
0
get_where_syntac() 함수를 살펴 보세요.
|