Class: Postgres
Source Location: /php/db/Postgres.php
Class Postgres
Inherited Properties, Constants, and Methods
Method Summary
bool |
begin() |
Æ®·£Àè¼Ç ½ÃÀÛ (±¸ÇöÁß) |
string |
error() |
¿¡·¯ ¸Þ¼¼Áö ¸®ÅÏ |
resource |
execute() |
prepare µÈ Äõ¸® ½ÇÇà |
array |
fetch() |
½ÇÇàµÈ select Äõ¸®¿¡ ´ëÇØ¼ fetch ¸¦ ÅëÇØ ÇÑ Çà(row)À» ¸®ÅÏÇÑ´Ù. |
void |
prepare() |
Äõ¸® ÆÄ½ÌÇϱâ (prepare) |
resource |
query() |
ÀÏ¹Ý Äõ¸® ½ÇÇà |
Methods
¿¡·¯ ¸Þ¼¼Áö ¸®ÅÏ
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()
- ¿¬°á ¸®¼Ò½º ¸®ÅÏ
|
|