Áö±ÝºÎÅÍ ÄíÅ°¸¦ ÀÌ¿ëÇÑ PHP + PostgreSQL¿ë °£´ÜÇÑ Ä«¿îÅ͸¦ ¸¸µé¾îº¸¸ç ¼³Ä¡°¡ Á¦´ë·Î µÇ¾ú´ÂÁö È®ÀÎÇØ º¸ÀÚ. »ç¿ëÀÚ °èÁ¤Àº suni00À¸·Î °¡Á¤ÇÏ°Ú´Ù.
$ su - postgres (»ç¿ëÀÚ¸¦ postgres·Î ¹Ù²Û´Ù) $ createuser suni00 (±ÇÇÑÀ» ÁÖ°íÇ °èÁ¤À» Àû´Â´Ù)DB »ý¼º ±ÇÇÑÀº ²À ÁÖ¾î¾ß ÇÑ´Ù.
$ su - suni00 (ÀϹݰèÁ¤ »ç¿ëÀÚ·Î ¹Ù²Û´Ù) $ createdb test (test¶õ DB¸¦ ¸¸µç´Ù) $ psql test (test DB¿¡ ¿¬°á) test=> create table counter ( count int ); (table »ý¼º) test=> insert into counter values ( 0 ); (0À» ÀÔ·Â) test=> \q (DB ºüÁ®³ª°¨)
<? $connect=pg_connect("dbname=test user=suni00"); $result=pg_exec($connect,"select * from counter"); $count_num = pg_result($result,0,"count"); if (!$counted) { $count_num++; pg_exec($connect,"update counter set count=$count_num"); } echo $count_num; ?>ÀÌÁ¦ À¥¿¡¼ ÀÌ ÆÄÀÏÀ» Àо¸é reload ÇÒ ¶§¸¶´Ù Çϳª¾¿ Ä«¿îÆ®°¡ Áõ°¡ÇÏ´Â°É ¾Ë ¼ö ÀÖ´Ù.
<? if (!$counted) { setcookie("counted",1,time()+3600); } ?>À§ ³»¿ëÀ» ´ëÃæ ¼³¸íÇϸé 3600ÃÊ(1½Ã°£)µ¿¾È $counted °ªÀ» 1·Î ¸¸µé¾î ÁØ´Ù. ±×·¯¹Ç·Î Çѹø Á¢¼ÓÇÑÈÄ 1½Ã°£ µÚ¿¡ Á¢¼ÓÇؾßÁö¸¸ Ä«¿îÅÍ´Â Áõ°¡ÇÑ´Ù.