Class: Postgres
Source Location: /php/db/Postgres.php
Class Postgres
Inherited Properties, Constants, and Methods
Method Summary
| bool |
begin() |
트랜잭션 시작 (구현중) |
| array |
fetch() |
실행된 select 쿼리에 대해서 fetch 를 통해 한 행(row)을 리턴한다. |
| resource |
query() |
일반 쿼리 실행 |
Methods
Postgres __construct(
[
$option = ''], [
$type = 'product']
)
|
|
생성자
Parameters:
API Tags:
Redefinition of:
- DBClient::__construct()
에러 메세지 리턴
API Tags:
| Return: | 에러 메세지 |
| Access: | public |
Redefinition of:
- DBClient::error()
- 에러 리턴
string escape(
string
$str
)
|
|
문자열 escape
Parameters:
|
string |
$str: |
escape 될 문자열 |
API Tags:
| Return: | escape 된 문자열 |
| Access: | public |
Redefinition of:
- DBClient::escape()
- 각각 DB별 문자열 escape
resource execute(
string
$name, [array
$data = array()]
)
|
|
prepare 된 쿼리 실행
$db = DB_('postgres','test', true);
$db->prepare('test_query', 'select * from test_table where id = $1');
echo $db->execute('test_query', array('test value'));
Parameters:
|
string |
$name: |
prepare된 쿼리 이름 |
|
array |
$data: |
바인딩될 값 리스트 |
API Tags:
| Return: | 실행된 결과 리소스 |
| Access: | public |
Redefinition of:
- DBClient::execute()
- prepare된 구문을 실행한다.
array fetch(
resource
$result
)
|
|
실행된 select 쿼리에 대해서 fetch 를 통해 한 행(row)을 리턴한다.
리턴되는 값은 array('필드' => 'ㅁㅁㅁ', ...); 형태를 가진다.
Parameters:
|
resource |
$result: |
select 결과로 나온 resource |
API Tags:
| Return: | row 데이타 |
| Access: | public |
Redefinition of:
- DBClient::fetch()
- 레코드 가져오기
DBData getData(
string|array
$query, [boolean
$isOne = false]
)
|
|
DBData 구함
$db->getData('select * from test_table');
$db->getData(array('select * from test_table where id = $1', array('aaa')));
$db->getData(array('sql' => 'select * from test_table where id = $1', 'param' => array('aaa')));
Parameters:
|
string|array |
$query: |
DB query |
|
boolean |
$isOne: |
인덱스 한칸 옮기기 |
API Tags:
Redefinition of:
- DBClient::getData()
- DBData 구함
int getFieldCount(
resource
$result
)
|
|
쿼리의 결과로 나온 필드의 개수를 리턴한다.
Parameters:
|
resource |
$result: |
select 결과로 나온 resource |
API Tags:
| Return: | 필드개수 |
| Access: | public |
Redefinition of:
- DBClient::getFieldCount()
- 필드 개수 가지고 오기
string getFieldName(
resource
$result, int
$i
)
|
|
정해진 위치의 필드 이름을 얻어온다.
Parameters:
|
resource |
$result: |
select 결과로 나온 resource |
|
int |
$i: |
필드 위치, 처음은 0 |
API Tags:
| Return: | 필드이름 |
| Access: | public |
Redefinition of:
- DBClient::getFieldName()
- 필드 이름 가지고 오기
string getFieldType(
resource
$result, int
$i
)
|
|
정해진 위치의 필드 타입을 얻어온다.
Parameters:
|
resource |
$result: |
select 결과로 나온 resource |
|
int |
$i: |
필드 위치, 처음은 0 |
API Tags:
| Return: | 필드타입 |
| Access: | public |
Redefinition of:
- DBClient::getFieldType()
- 필드 타입 가지고 오기
DBData getPageData(
string|array
$query, int
$page, [int
$count = 10]
)
|
|
select 쿼리에 대해서 페이징된 DBData를 리턴한다.
$db->getPageData(array('select * from test_table where id = $1', array('aaa')), 1, 10);
$db->getPageData(array('sql' => 'select * from test_table where id = $1', 'param' => array('aaa')), 1, 10);
Parameters:
|
string|array |
$query: |
select 쿼리 |
|
int |
$page: |
현재 페이지 |
|
int |
$count: |
페이지당 리스트 개수 |
API Tags:
Redefinition of:
- DBClient::getPageData()
- paging 된 DBData 얻어오기
void prepare(
string
$name, string
$query
)
|
|
쿼리 파싱하기 (prepare)
$db->prepare("test_query", 'select * from test_table where id = $1');
Parameters:
|
string |
$name: |
prepare될 구문 이름 |
|
string |
$query: |
prepare될 구문, 구문중에 바인될 변수는 $1,$2 와 같은 형태로 표시된다. |
API Tags:
Redefinition of:
- DBClient::prepare()
- prepare
resource query(
$query, [array
$param = array()], string
$sql
)
|
|
일반 쿼리 실행
$db = DB_('postgres', 'test', true);
// 1. 기본 쿼리 실행
$db->query("insert into test_table values ('123', '456')");
// 2. 바인딩 쿼리 실행
$db->query('insert into test_table values ($1, $2)', array('123','456'));
Parameters:
|
string |
$sql: |
실행될 query , 바인딩 될 곳은 $1, $2 와 같은 형태로 표시 |
|
array |
$param: |
바인딩될 변수 |
|
|
$query: |
|
API Tags:
| Return: | 실행 resource |
| Access: | public |
Redefinition of:
- DBClient::query()
- 쿼리 실행하기
커서 이동
Parameters:
|
int |
$count: |
이동시킬 상대위치, 사직행은 0 |
API Tags:
Redefinition of:
- DBClient::seek()
- result set 이동
database 연결 생성
API Tags:
| Return: | 연결 resource |
| Access: | protected |
Redefinition of:
- DBClient::_connect()
- 연결 리소스 리턴
|
|