| 제목 | sqlite3_driver.php에 list_fields() 추가하기 | ||
|---|---|---|---|
| 글쓴이 | letsgolee | 작성시각 | 2014/07/19 09:21:33 |
|
|
|||
|
Codeigniter 3.0을 사용하면서 mysql로 작업하던 것을 sqlite3로 옮겨올 때 함수 처리가 문제가 되더라구요. 예를 든다면 Tank_Auth에서 Unix_timestamp()함수를 쓰는데 sqlite3에는 이게 지원되지 않습니다. 그래서 파일을 수정해서 strftime('%s', field_name)이런 식으로 지원되게 하는 방향으로 했는데 또 에러가 나서 로그를 보니 list_fields를 쓰는 곳에서 에러가 납니다. 소스를 뜯어보니 sqlite3에서는 _list_columns() 결과가 false가 되어 list_fields가 지원이 안되는 겁니다. 문제는 field_data()는 지원되면서... 그래서 이 함수를 이용해 list_fields()를 만들어 보았습니다. 이 함수를 sqlite3_driver.php 안에 넣어주시면 됩니다.
/**
* Fetch Field Names
*
* @param string the table name
* @return array
*/
public function list_fields($table = '')
{
// Is there a cached result?
if (isset($this->data_cache['field_names'][$table]))
{
return $this->data_cache['field_names'][$table];
}
if ($table === '')
{
return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
}
$result = $this->field_data($table);
$this->data_cache['field_names'][$table] = array();
foreach ($result as $row)
{
$this->data_cache['field_names'][$table][] = $row->name;
}
return $this->data_cache['field_names'][$table];
}
|
|||
| 다음글 | view를 이용한 테마기능 구현 (1) | ||
| 이전글 | 아이피 주소로 위치정보를... (3) | ||
|
변종원(웅파)
/
2014/07/21 10:07:58 /
추천
0
팁 감사합니다. ^^
|
|
한대승(불의회상)
/
2014/07/21 13:38:53 /
추천
0
좋은 정보 감사 합니다.
|