· KLDP.org · KLDP.net · KLDP Wiki · KLDP BBS ·
Linuxdoc Sgml/PHP-HOWTO

<!doctype linuxdoc system>
<!-- 

************************** begin comment *****************************
     The following is the HOW-TO for programming in PHP.
	 This document is in the SGML format. You must use sgml package to 
	 process this document
************************* end of comment *****************************

-->
<!--
************************** SGML USER GUIDE *****************************
	The SGML user guide on linux is located at /usr/doc/sgml-tools
	Read the example.sgml and guide.html documents.
	Usage:
		HTML	  	sgml2html foo  (Do not give extension .sgml here!!)
		Text	 	sgml2txt foo.sgml
		Latex	  	sgml2latex foo.sgml

		Note: Use 2 dashes - before language, error while compiling
		Postscript 	sgml2latex -language=english -o ps foo.sgml
		DVI  		sgml2latex -d foo.sgml
		Lyx			sgml2lyx foo.sgml
		Richtext 	sgml2rtf foo.sgml
		gnuinfo  	sgml2info foo.sgml
		man			sgml2txt -man foo.sgml
		SGML	 	sgmlcheck foo.sgml
************************* end of comment *****************************
-->

<article>

<!-- Title information -->

<title>PHP ÇÏ¿ìÅõ
<!-- chapt change
PHP ÇÏ¿ìÅõ



-->
<author>Al Dev (Alavoor Vasudevan) 
       <htmlurl url="mailto:
	   		alavoor@yahoo.com
			" name="
			alavoor@yahoo.com
		">
<date>v8.0, 26 Sep 2000

<trans>À±±¤È£(KwangHo, Yun), 
      <htmlurl url="mailto:airplanez@kldp.org" name="airplanez@kldp.org">
<tdate>PHP-HOWTO_kr.sgml, v0.01 2000/11/07 15:50

<abstract>
À̹®¼­´Â ¾î¶»°Ô PHP ÇÁ·Î±×·¥À» ¸¸µå´ÂÁö¿Í Windows 95 GUI ¾îÇø®ÄÉÀ̼ÇÀ» ÈǸ¢ÇÑ 
PHP + HTML + DHTML + XML + Java applets + Javascript ·Î ¹Ù²Ù´Â °ÍÀ» ¼³¸íÇÒ°ÍÀÌ´Ù.
À̹®¼­¿¡ ÀÖ´Â Á¤º¸´Â PHP°¡ Æ÷ÆÃ µÇ¾îÀÖ´Â Linux, Windows 95/NT, OS/2, 
Unix °è¿­ÀÇ Solaris, HPUX, AIX, SCO, Sinix, BSD, µîµîÀÇ ¿î¿µÃ¼°è¿¡ Àû¿ëµÈ´Ù.
</abstract>

<!-- Table of contents -->
<toc>

<!-- Begin the document -->

<!-- 
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt>¼Ò°³
-->
<sect>¼Ò°³
<p>
PHP ´Â 'Hypertext Pre-Processor'¸¦ ÀǹÌÇÏ°í ¼­¹ö»çÀ̵å(server side)
HTML ½ºÅ©¸³ÆÃ/ÇÁ·Î±×·¡¹Ö ¾ð¾îÀÌ´Ù.
PHP´Â µ¿ÀûÀÎ À¥ÆäÀÌÁö¸¦ ¸¸µé¼ö ÀÖ°ÔÇØÁØ´Ù. PHP°¡ »ç¿ëµÈ À¥ÆäÀÌÁö´Â ÀϹÝÀûÀÎ
HTML ó·³ Ãë±ÞµÇ¸ç Æò¹üÇÑ HTML ÆäÀÌÁöó·³ »ý¼º°ú ¼öÁ¤À» ÇÒ¼ö ÀÖ´Ù.

¸¹Àº ȸ»çµéÀÌ PHP´Â <bf>"Á߿亸¾È°ú ¾ö°ÝÇÑ ºñ¹Ð"</bf>À» À¯ÁöÇÒ¼ö ÀÖ´Â 
ÄÄÇ»ÅÍ ¾ð¾î¶ó°í ¸»ÇÏÁö¸¸, ±×·¯³ª Áö±ÝÀº À߾˷ÁÁö°í ¸¹ÀÌ ¾²ÀÌ´Â À¥, ÀÎÅͳÝ, ÀüÀÚ»ó°Å·¡¿Í 
B2B(business-to-business) ÇÁ·ÎÁ§Æ®À» À§ÇÑ ½ºÅ©¸³Æ® ¾ð¾î°¡ µÇ¾ú´Ù.
±×·³¿¡µµ ºÒ±¸ÇÏ°í ¿äÁò ¸¹Àº °æÀïȸ»çµéÀÌ PHP¾ð¾î¸¦ º¸¾È¿¡ ´ëÇØ¼­ 
¾ÈÀüÇÏÁö¾Ê´Ù°í ÇÑ´Ù(°æÀïÀÚµé).(¿ªÁÖ:¹ø¿ªÀÌ ¿µ ÀÌ»óÇϳ×..)
  

PHP´Â Àü¼¼°è¿¡ µ¹Ç³À» ÀÏÀ¸Å³ °ÍÀ̸ç IT¾÷°è¸¦ ³î¶ø°Ô Á¡À¯ÇÏ°Ô µÉ°ÍÀÌ´Ù!!
PHPÀÇ ÆÄ¿ö´Â <bf>Å©·Î½º-Ç÷§Æû ÀÌ°í ¾î´À°÷¿¡¼­µµ ½ÇÇàµÈ´Ù!!</bf>
PHP´Â ¸®´ª½º, À©µµ 95/98/NT, À©µµ 2000, ¼Ö¶ó¸®½º, HPUX¿Í ¸ðµç À¯´Ð½º 
°è¿­¿¡¼­ ½ÇÇàµÈ´Ù. PHP´Â ÇѹøÀÛ¼º µÇ¸é ¾îµð¼­³ª ½ÇÇàµÈ´Ù.
PHP´Â ¾ÆÆÄÄ¡, ¸¶ÀÌÅ©·Î¼ÒÇÁÆ® IIS µîµîÀÇ ¸¹Àº À¥¼­¹ö¿¡¼­ ½ÇÇàµÈ´Ù.

PHP´Â ÀÚ¹Ùº¸´Ù 5¿¡¼­ 20¹è±îÁö ºü¸£´Ù!! PHP´Â »ç¿ëÇϴµ¥ ¹«Ã´½±°í, ¸Å¿ì º¹ÀâÇÑ
À¥/ÀüÀÚ»ó°Å·¡ ¾îÇø®ÄÉÀ̼ÇÀ» ¸Å¿ì ºü¸£°í ªÀº ½Ã°£¿¡ °³¹ßÇÒ¼ö ÀÖ´Ù.

PHP´Â °´Ã¼ÁöÇâÀûÀΠƯ¡°ú ÀÚ¹Ù, C++, PERL°ú "C"·Î ºÎÅÍ ÈǸ¢ÇÑ Æ¯Â¡À» °¡Á®¿Ô´Ù.
PHP¾ð¾î´Â ÀÚ¹Ù, C++, PERL°ú CÀÇ ÈǸ¢ÇÑ Æ¯Â¡ÀÇ °áÇÕüÀÌ´Ù.

PHP´Â ¸ðµç ½ºÅ©¸³Æ®/ÇÁ·Î±×·¥ ¾ð¾îÀÇ <bf>ÁøÁ¤ÇÑ º¸¼®</bf>ÀÌ¸ç °ð Àü¼¼°è 
ÇÁ·Î±×·¡¸ÓÀÇ "¸ÞÄ«"°¡ µÉ°ÍÀÌ´Ù!!
PHP´Â À©µµ 95/NT ¿Í ¸ðµç À¯´Ð½º¿¡¼­ ½ÇÇàµÇ±â ¶§¹®¿¡ °Å´ëÇÑ »ç¿ëÀÚÃþ°ú 
¸¹Àº °³¹ßÀÚÃþÀ» °¡Áø´Ù.

PHP´Â º¸´Ù ºü¸£°Ô ½ÇÇàµÇµµ·Ï Á¨¿ÉƼ¸¶ÀÌÀú(Zend Optimizer)¸¦ »ç¿ëÇÏ¿© 
ÄÄÆÄÀϰú ÃÖÀûÈ­(optimized)½Ãų¼ö ÀÖ´Ù. Á¨¿ÉƼ¸¶ÀÌÀú(Zend Optimizer)´Â
PHP ¹öÀü 4.0¿¡¼­ ºÎÅÍ PHP¿¡ ÅëÇյǾú´Ù. - 2009.4.17 ¿©ÀüÈ÷ zend.com ¿¡¼­ ¹Þ¾Æ ¼³Ä¡ÇØ¾ß ÇÕ´Ï´Ù. php ÀÇ ¿£Áø À̸§ÀÌ zend engine ÀÌ¶ó¼­ Çò°¥¸± ¼ö´Â ÀÖÁö¸¸ zend optimizer ´Â ÅëÇÕµÇÁö ¾Ê¾Ò½À´Ï´Ù. ¼ÛÈ¿Áø

´ç½ÅÀº ÀüÀÚ»ó°Å·¡(e-commerce) ÇÁ·ÎÁ§Æ®¸¦ Çϴµ¥ º¸Åë PHP (70% ÄÚµå) + 
HTML/DHTML/XML (25% ÄÚµå) + Javascript (5% ÄÚµå Ŭ¶óÀÌ¾ðÆ® Ãø) ÀÇ Á¶ÇÕÀ» 
»ç¿ëÇÒ°ÍÀÌ´Ù. 
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt> PHP ³»·Á¹Þ±â<label id = "PHP Download">
-->
<sect> PHP ³»·Á¹Þ±â<label id = "PHP Download">
<p>
<itemize>
<item> PHP ¸ÞÀÎ »çÀÌÆ® <url url="http://www.php.net">
<item> PHP ¸®¼Ò½º <url url="http://ils.unc.edu/web-db/php/links.html">
<item> PHP ÄÚµå º¯È¯ - <url url="http://px.sklar.com">
</itemize>
<!--
	*******************************************
	************ End of Section ***************
	*******************************************

-->
<sect1> Microsoft Windows 95/98/NT/2000¿¡ PHP ¼³Ä¡<label id = "PHP Installation">
<p>
PHP´Â Microsoft Windows Ç÷¿Æû¿¡¼­ ¸Å¿ì ÀαâÀÖ°í ³î¶ø°Ôµµ MS ÀÇ ASP ½ºÆ®¸³Æ® 
¾ð¾îº¸´Ù ´õ ÀαâÀÖ´Ù!!
PHPÀÇ °¡ÀåÅ« ÀåÁ¡Àº MS À©µµ¿Í ¸®´ª½º, À¯´Ð½º¿¡¼­ °³¹ßÇÒ¼ö ÀÖ°í ¹Ý´ë·Î 
»ç¿ëÇÒ¼öµµ ÀÖ´Ù´Â °ÍÀÌ´Ù!!

MS À©µµ 98/NT/2000 ¿¡¼­ PHPÀÇ ¼ö¿ä°¡ ¸¹±â ¶§¹®¿¡ ½ÇÇà°¡´ÉÇÑ ¼³Ä¡ÇÁ·Î±×·¥ÀÌ ÁغñµÇ¾î ÀÖ´Ù.
´ÜÁö ½ÇÇàÈ­ÀÏÀ» ´õºíŬ¸¯ ÇÏ´Â °Í¸¸À¸·Î 2ºÐ¸¸¿¡ PHP¼³Ä¡°¡ ÀÚµ¿À¸·Î ÀÌ·ç¾îÁø´Ù.
½ÇÇà°¡´ÉÇÑ ¼³Ä¡È­ÀÏÀ» ´Ù¿î·ÎµåÇ϶ó.
<itemize>
<item> MS WindowsÀÇ PHP ¼³Ä¡ ÇÁ·Î±×·¥ <url url="http://php.weblogs.com/easywindows">
<item> ¸¹Àº À©µµ Ç÷¿ÆûÀÇ PHP Á¤º¸ <url url="http://php.weblogs.com">
</itemize>
<!--
	*******************************************
	************ End of Section ***************
	*******************************************

-->
<sect1> À¯´Ð½ºµé°ú ´Ù¸¥ Ç÷¿Æû¿¡¼­ PHP ¼³Ä¡<label id = "PHP Installation">
<p>
PHP ¸ÞÀλçÀÌÆ®<url url="http://www.php.net"> ³ª ´Ù¿î·ÎµåÇÑ ÆÐŰÁöÀÇ ¼³Ä¡ÆÄÀÏ
¿¡¼­ ¼³Ä¡°¡À̵å¿Í Áö½Ã¸¦ º¸¶ó.
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt> PHP Æ©Å丮¾ó <label id = "PHP Tutorial">
-->
<sect> PHP Æ©Å丮¾ó <label id = "PHP Tutorial">
<p>
¿©±â¿¡¼­´Â ´ç½ÅÀÇ ¼­¹ö°¡ PHP °¡ °¡´ÉÇϰí .php3·Î ³¡³ª´Â ¸ðµç È­ÀÏÀÌ 
PHP¿¡ ÀÇÇØ ½ÇÇàµÈ´Ù°í °¡Á¤ÇÑ´Ù.

ù¹øÂ° PHP°¡ °¡´ÉÇÑ ÆäÀÌÁö:
´ÙÀ½ÀÇ ¶óÀÎÀ» ³Ö¾î¼­ hello.php3¶õ È­ÀÏÀ» ¸¸µé¾î¶ó:
<code>
      <html>< head>< title >PHP Test< /title >< /head >
      < body>
      <?php echo "Hello World<P>"; ?>
      < /body>< /html>
</code>

CGI ½ºÅ©¸³Æ® ó·³ º¸ÀÌÁö ¾ÊÀ»°ÍÀÌ´Ù.
Ưº°ÇÑ Å±׸¦ °¡Áö°í ÀÖ´Â º¸Åë HTML ó·³ »ý°¢Ç϶ó.

¸¸¾à À̰ÍÀ» ½ÇÇàÇߴµ¥ ¾Æ¹«·± °á°úµµ ³ªÅ¸³ªÁö ¾ÊÀ¸¸é, PHP°¡ ½ÇÇàµÇÁö ¾ÊÀº °ÍÀÌ´Ù.
´ç½ÅÀÇ °ü¸®ÀÚ¿¡°Ô ½ÇÇàµÇ°Ô ÇØ´Þ°í ¿äûÇ϶ó.

À̹ø ¿¬½À¿¡¼­´Â PHPÀÇ Æ¯º°ÇÑ Å±׸¦ º¸¿©ÁÖ±â À§ÇѰÍÀÌ ¸ñÀûÀÌ´Ù. À̹ø ¿¬½À¿¡¼­
¿ì¸®´Â PHP ű×ÀÇ ½ÃÀÛÀ» ¾Ë¸®´Â < ?php¸¦ »ç¿ëÇÏ¿´´Ù. ±×¸®°í PHP ¹®ÀåÀ» ³Ö°í 
? > ű׸¦ ³¡¿¡ ³Ö¾ú´Ù.  ´ç½ÅÀº ´ç½ÅÀÌ HTML È­ÀÏÀÇ ¿øÇÏ´Â °÷¿¡ ÀÌ·¸°Ô ÇÔÀ¸·Î¼­ 
PHP ¸ðµå¸¦ ½ÃÀÛÇÏ°í ³¡³¾¼ö ÀÖ´Ù.

¿ì¸®´Â ÆäÀÌÁö¸¦ º¸´Â »ç¶÷ÀÌ ¾î¶² ºê¶ó¿ìÀú¸¦ »ç¿ëÇÏ´ÂÁö °Ë»çÇØº¼°ÍÀÌ´Ù. 
±×·¸°Ô ÇϱâÀ§ÇØ ¿ì¸®´Â ºê¶ó¿ìÀú°¡ º¸³»¿Â ¿äû¿¡ ´ëÇÑ ºÎºÐÀ» üũÇÑ´Ù.
ÀÌ Á¤º¸´Â º¯¼ö¿¡ ÀúÀåµÈ´Ù. º¯¼ö´Â ¾ðÁ¦³ª ´Þ·¯»çÀÎ($)À¸·Î ½ÃÀÛÇÑ´Ù. ¿ì¸®°¡
°ü½ÉÀ» °¡Áö´Â º¯¼ö´Â $HTTP_USER_AGENT ÀÌ´Ù. À̰ÍÀ» º¸¿©ÁÖ±â À§Çؼ­ ¿ì¸®´Â
´ÙÀ½°ú °°ÀÌ ÇÒ¼ö ÀÖ´Ù:
<code>
      <?php echo $HTTP_USER_AGENT; ?>
</code>

Áö±Ý ´ç½ÅÀÌ ÀÌ ÆäÀÌÁö¸¦ º¸±â À§ÇØ »ç¿ëÇÏ´Â ºê¶ó¿ìÀú¿¡¼­´Â, ÀÌ·¸°Ô ³ª¿Â´Ù:

     Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)

ÀÚ½ÅÀÇ À¥¼­¹ö¿¡ ÀÇÇØ ÀÚµ¿À¸·Î ¼³Á¤µÇ´Â ¸¹Àº ´Ù¸¥ º¯¼öµéÀÌ ÀÖ´Ù.
´ÙÀ½°ú °°Àº È­ÀÏÀ» ¸¸µêÀ¸·Î¼­ ¿ÏÀüÇÑ º¯¼öÀÇ ¸®½ºÆ®¸¦ ¾òÀ»¼ö ÀÖ´Ù:
<code>
      <?php phpinfo()?>
</code>

ºê¶ó¿ìÀú·Î ÀÌÈ­ÀÏÀ» ÀоîµéÀ̸é ÀÚ½ÅÇѵ¥ °¡¿ëÇÑ ¸ðµç º¯¼öÀÇ ¸®½ºÆ®¸¦ È­¸é°¡µæ
ÇÑ Á¤º¸¿Í °°ÀÌ º¼¼ö ÀÖÀ»°ÍÀÌ´Ù.

PHP ű׾ȿ¡ ¿©·¯°³ÀÇ PHP ¹®ÀåÀ» Áý¾î³ÖÀ»¼ö ÀÖÀ¸¸ç ÇϳªÀÌ»óÀÇ echo ¹®À» °¡Áö´Â
ÄÚµåºí·°À» ¸¸µé¼ö ÀÖ´Ù. 
<code>
      <?php
      if(strstr($HTTP_USER_AGENT,"MSIE")) {
          echo "You are using Internet Explorer<br>";
      }
      ?>
</code>

¿©±â¿¡¼­´Â PHP ºí·°ÀÇ Áß°£ÀÏÁö¶ó°í PHP¸ðµå¸¦ ¹þ¾î³ª´Â ¹æ¹ýÀ» º¸¿©ÁÙ°ÍÀÌ´Ù:

<code>
	<?php
	if(strstr($HTTP_USER_AGENT,"MSIE")) 
	{
		?>
		< center>< b>You are using Internet Explorer< /b>< /center>
		<?
	} 
	else 
	{
		?>
		< center>< b>You are not using Internet Explorer< /b>< /center>
		<?
	}
	?>
</code>
PHPÀÇ echo ¹®À» »ç¿ëÇÏ´Â ´ë½Å PHP ¸ðµå¸¦ ¹þ¾î³ª¼­ Á÷Á¢ HTML À» ³ÖÀ»¼ö ÀÖ´Ù.
¿©±â¼­ ¸»ÇÏ·Á°í ÇÏ´Â Áß¿äÇÏ°í °­·ÂÇÑ Á¡Àº ³í¸®ÀûÀÎ È帧ÀÌ ±úÁöÁö ¾Ê°í ³²¾Æ 
ÀÖ´Ù´Â °ÍÀÌ´Ù. ´ÜÁö HTML ºí·°µéÀº °á±¹ º¸´Â »ç¶÷¿¡°Ô¸¸ º¸³»Áö°Ô µÇ´Â°ÍÀÌ´Ù.
½ºÅ©¸³Æ®¸¦ ½ÇÇà½ÃŰ¸é °á°ú´Â ´ÙÀ½°ú °°´Ù :

                       You are using Internet Explorer

Æû ´Ù·ç±â

PHPÀÇ °¡Àå À¯¿ëÇÑ ±â´ÉÁß Çϳª°¡ HTML Æû(form)À» ´Ù·ç´Â ¹æ¹ýÀÌ´Ù.
±×°ÍÀ» ÀÌÇØÇÏ´Â Áß¿äÇÑ ±âº»ÀûÀÎ °³³äÀº Æû¿¡ ³ª¿Â ¸ðµç ¿ä¼ÒµéÀÌ ÀÚµ¿ÀûÀ¸·Î 
Æû¿¡ ÀÖ´Â À̸§°ú °°Àº º¯¼ö·Î ÀÚµ¿ÀûÀ¸·Î ¹Ù²î¾î ºÒ·ÁÁø(target) °÷¿¡¼­ »ç¿ë
µÈ´Ù´Â °ÍÀÌ´Ù. º¹ÀâÇÏ°Ô µé¸±°ÍÀÌ´Ù. ±×·¡¼­ ¿©±â °£´ÜÇÑ ¿¹Á¦°¡ ÀÖ´Ù.
´ÙÀ½°ú °°Àº ÆûÀ» °¡Áö´Â ÆäÀÌÁö°¡ ÀÖ´Ù°í °¡Á¤Ç϶ó :
<code>
      <form action="action.php3" method="POST">
      Your name: <input type=text name=name>
      You age: <input type=text name=age>
      <input type=submit>
      < /form>
</code>
¿©±â¿¡ ÀÖ´Â Æû¿¡´Â ¾î¶°ÇÑ Æ¯º°ÇÑ °Íµµ¾ø´Ù. ¾î¶² Ưº°ÇÑ Å±׵µ ¾ø´Â ´ÜÁö HTML Æû¿¡ 
ºÒ°ú ÇÏ´Ù. »ç¿ëÀÚ°¡ ÆûÀ» ÀÔ·ÂÇϰí Àü¼Û¹öưÀ» ´©¸®¸é action.php3°¡ ºÒ·ÁÁø´Ù.
ºÒ·ÁÁø È­ÀÏ¿¡´Â ´ÙÀ½°ú °°Àº °ÍÀÌ µé¾îÀÖÀ»°ÍÀÌ´Ù:
<code>
      Hi <?php echo $name?>.  You are <?php echo $age?> years old.
</code>
³î¶ø°Ôµµ $name°ú $age º¯¼ö´Â PHP¿¡ ÀÇÇØ ÀÚµ¿À¸·Î Á¤ÇØÁø´Ù!!
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt> PHPÀ» À§ÇÑ IDE(ÅëÇÕȯ°æ) µµ±¸<label id = "PHP IDE">
-->
<sect> PHPÀ» À§ÇÑ IDE(ÅëÇÕȯ°æ) µµ±¸ <label id = "PHP IDE">
<p>
¸¹Àº HTML ¿¡µðÅ͵éÀº PHP¸¦ Áö¿øÇÑ´Ù :
<itemize>
<item>SoyalÀÇ ÈǸ¢ÇÑ PHP ¿¡µðÅÍ <url url="http://soyal.free.fr/PHPEd">
<item>Blue Fish <url url="http://bluefish.linuxave.net" >
<item>Coffee cup <url url="http://www.coffeecup.com/linux" >
<item>µå¸²À§¹ö(Dreamweaver) <url url="http://www.dreamweaver.com" >
<item>Amaya <url url="http://www.w3.org/Amaya" >
<item>Homesite <url url="http://www.allaire.com/homesite" >
<item>Hotdog <url url="http://www.hotdog.com" >
<item> Zend Optimizers(Àü¿ÉƼ¸¶ÀÌÁ®) <url url="http://www.zend.com">
<item> Zend Compilers(ÀüÄÄÆÄÀÏ·¯) <url url="http://www.zend.com" >
<item> MS Windows Ç÷¿Æû¿ëÀÇ ¸¹Àº PHP Á¤º¸ <url url="http://php.weblogs.com">
</itemize>
°¡±î¿î ½ÃÀÏ¿¡ ¸ðµç HTML ¿¡µðÅÍ¿Í XML ¿¡µðÅͰ¡ "ºü¸¥ ¾îÇø®ÄÉÀÌ¼Ç °³¹ß" µµ±¸·Î 
PHP¸¦ Áö¿øÇÒ°ÍÀÌ´Ù.
.
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt> PHP¸¦ À§ÇÑ ctags !! <label id = "ptags">
-->
<sect> ³î¶ó¿î !!! PHP¸¦ À§ÇÑ ctags ! <label id = "ptags">
<p>
ÀÌ Å±׵éÀº »ó´çÈ÷ Áß¿äÇϰí vi, emacs, CRiSP, NEdit µî°ú °°Àº ¿¡µðÅÍ·Î ¼Ò½ºÄڵ带 
Ž»ö(°Ë»ö)Çϴµ¥ ¾²¿©Áø´Ù. ¸¸¾à C, C++ ¶Ç´Â ÀÚ¹Ù·Î ÇÁ·Î±×·¥ÇÑ °ÍÀ» °¡Áö°í ÀÖ´Ù¸é
ű׸¦ »ý¼ºÇϱâ À§ÇØ <bf>ctags</bf> ÇÁ·Î±×·¥À» »ç¿ëÇÒ¼ö ÀÖÀ»°ÍÀÌ´Ù.
¿Â¶óÀÎ ¸Þ´º¾ó ÆäÀÌÁö(online manual page)¸¦ º¸±âÀ§Çؼ­´Â ¸®´ª½º/À¯´Ð½º bash prompt
¿¡¼­ 'man ctags'¸¦ Ä¡¸é µÈ´Ù.

PHP¸¦ À§ÇÑ <bf>ptags</bf> ÇÁ·Î±×·¥Àº ´ÙÀ½¿¡ ÀÖ´Ù. ±×°ÍÀ» »ç¿ëÇϸé PHP ¼Ò½ºÄڵ带
À§ÇÑ Å±׸¦ »ý¼ºÇÒ¼ö ÀÖ´Ù. <bf>ptags</bf>¸¦ »ç¿ëÇÏ¸é ´ç½ÅÀÇ <bf>»ý»ê¼ºÀº 3¿¡¼­ 
4¹è±î·® Çâ»óµÉ°ÍÀÌ´Ù</bf>.

¶ÇÇÑ <url url="http://metalab.unc.edu/LDP/HOWTO/Vim-HOWTO.html">¿¡ ÀÖ´Â PHP, C, C++¸¦
À§ÇÑ Vim Ä÷¯ ÅØ½ºÆ® ¿¡µðÅ͸¦ ÂüÁ¶Ç϶ó.

<code>
// ptags.cpp·Î ÀÌÈ­ÀÏÀ» ÀúÀåÇϰí 
// g++ -o ptags ptags.cpp ·Î ÄÄÆÄÀÏÇ϶ó.
//*****************************************************************
// GNU/GPL ÀúÀÛ±ÇÀ» µû¸¥´Ù. Ãß°¡·Î º¹»ç¸¦ ÇϰԵǸé ÀúÀÚÀÇ À̸§,
// À̸ÞÀÏÀ» Æ÷ÇÔ½ÃÄѶó.
// ÀúÀÚ : Al Dev Email: alavoor@yahoo.com
// Usage : ptags *.php3 *.inc
// 		   This will generate a file called tags
//*****************************************************************
#include <iostream.h>
#include <fstream>
#include <stdio.h> // for sprintf
#include <stdlib.h> // for system
#include <string.h> // for memset
#include <ctype.h> // for isspace

#define	BUFF_LEN  1024
#define	LOCATION  9

char *ltrim(char *dd);
char *rtrim(char *ee);

main(int argc, char **argv)
{
	if (argc < 2)
	{
		cerr << "\nUsage: " << argv[0] << " file .... " << endl;
		exit(0);
	}

	char fname[100] = "tag_file.out";
	FILE	*fpout;
	ofstream    fout(fname);
	if (fout.fail())
	{
		cerr << "\nError opening file : " << fname << endl;
		exit(-1);
	}
	//fpout = fopen(fname, "w");

	for (int ii = 1; ii < argc; ii++)
	{
		/*
		char buff[2024];

		sprintf(buff, "\\rm -f %s; ls %s > %s 2>/dev/null", outfile, argv[1], outfile);
		cout << "\nbuff = " << buff << endl;

		system(buff);
		fclose(fp);
		*/
		FILE *fpin = NULL;
		fpin = fopen(argv[ii], "r");
		if (fpin == NULL)
		{
			cerr << "\nError opening file : " << argv[ii] << endl;
			exit(-1);
		}
		char buff[BUFF_LEN + 100];
		memset(buff, 0, BUFF_LEN +10);
		for ( ; fgets(buff, BUFF_LEN, fpin) != NULL; )
		{
			char aa[BUFF_LEN + 100];
			memset(aa, 0, BUFF_LEN +10);
			strcpy(aa, buff);
			ltrim(aa);

			// Remove the trailing new line..
			{
				int tmpii = strlen(aa);
				if (aa[tmpii-1] == '\n')
					aa[tmpii-1] = 0;
			}
			//cout << "aa is : " << aa << endl;
			if (strncmp(aa, "function ", LOCATION) != 0)
				continue;
			//cout << buff << endl;

			// Example tags file output is like -
			// al2	al.c	/^al2()$/;"	f
			{
				char bb[BUFF_LEN + 100];
				memset(bb, 0, BUFF_LEN +10);
				strcpy(bb, & aa[LOCATION]);
				char *cc = bb;
				while (cc != NULL && *cc != '(')
					*cc++;
				*cc = 0;
				cc = rtrim(bb);
				//cout << "bb is : " << bb << endl;
				//cout << cc << "\t" << argv[ii] << "\t" << "/^" << aa << "$/;\"\tf" << endl;
				fout << cc << "\t" << argv[ii] << "\t" << "/^" << aa << "$/;\"\tf" << endl;
				//fprintf(fpout, "%s\t%s\t/^%s$/;\"f\n", cc, argv[ii], aa );
			}

			memset(buff, 0, BUFF_LEN +10);
		}
		fclose(fpin);
	}
	fout.flush();
	fout.close();
	//fclose(fpout);

	// Sort and generate the tag file
	{
		char tmpaa[1024];
		sprintf(tmpaa, "sort %s > tags; \\rm -f %s", fname, fname);
		system(tmpaa);
	}
}

char *ltrim(char *dd)
{
    if (dd == NULL)
        return NULL;

    while (isspace(*dd))
        dd++;
	
	return dd;
}

char *rtrim(char *ee)
{
    if (ee == NULL)
        return NULL;

	int tmpii = strlen(ee) - 1;
	for (; tmpii >= 0 ; tmpii--)
	{
		if (isspace(ee[tmpii]) )
		{
			//cout << "\nis a space!!" << endl;
			ee[tmpii] = 0;
		}
	}
	return ee;
}
</code>
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt> PHP µð¹ö±ë <label id = "debugphp">
-->
<sect> PHP µð¹ö±ë <label id = "debugphp">
<p>
PHP ÇÁ·Î±×·¥À» µð¹ö±ë ÇÏ·Á¸é ´ÙÀ½ÀÇ ÇÔ¼ö¸¦ °¡Áö´Â "debug2.inc"À̶õ 
È­ÀÏÀ» ¸¸µé¾î¶ó :
<code>
<?php

/* ÀÌÁßÀ¸·Î ¼±¾ðµÇ´Â °ÍÀ» ¹æÁöÇϱâ À§ÇÑ º¯¼öÁ¤ÀÇ */
if (!defined("_DEBUG2_DEFINED_")) 
{
	define("_DEBUG2_DEFINED_", 1 );
}
else
	return; // ¸¸¾à ÀÌÈ­ÀÏÀÌ include µÆ´Ù¸é ¸®ÅÏ
# file name : debug2.inc
# PHP ¼Ò½º Äڵ带 µð¹ö±ëÇϱâ À§ÇÑ ÇÔ¼öµé
#*****************************************************************
# Copyright policy is GNU/GPL but additional request is
# that you include author's name and email on all copies
# Author : Al Dev Email: alavoor@yahoo.com
#*****************************************************************

# Usage of this functions -
# In your source code put something like -
# debug2_(__FILE__, __LINE__, "f_somevariable", $f_somevariable);
# And this will generate output in debug.out file.

//function debug2_($fname, $lname, $debug_var, $debug_value=0) {}

// Give read, exec for all on directory /debug2_logs
// chmod a+rwx /debug2_logs
// But here you need to open the file in append mode.
$fp_debug2 = fopen("/debug2_logs/debug.out", "a");
if ($fp_debug2 == false)
{
	print "<b>File open failed - global.var.inc<b>";
	exit;
}

function debug2_($fname, $lname, $debug_var, $debug_value=0)
{
	global $fp_debug2;

	//print "<br> debug_value is : $debug_value <br>";
	if (!$debug_value)
	{
		fwrite($fp_debug2, "\n ". $fname ."  ". $lname .": $debug_var");
	}
	else
	{
		fwrite($fp_debug2, "\n ". $fname . " ". $lname .": $debug_var = $debug_value");
	}
	//print "<br> f_cookie is : $f_cookie <br>";
}

// In your first page, which is generally index.php3 
// truncate the debug2_logs file in beginning of code
function init_debug_file()
{
	global $fp_debug2;

	$fp_debug2 = fopen("/debug2_logs/debug.out", "w");
	if ($fp_debug2 == false)
	{
		print "<b>File open failed - global.var.inc<b>";
		exit;
	}
	system("chmod a+rwx /debug2_logs/debug.out");
}

?>
</code>

º¸Åë index.php3·Î µÇ´Â ½ÃÀÛÆäÀÌÁöÀÇ PHP ¼Ò½ºÄڵ忡 ´ÙÀ½À» Áý¾î³Ö¾î¶ó.
<code>
<?php
	include ("debug2.inc");

	init_debug_file();
	// ´Ù¸¥ ¸í·ÉÀº ¿©±â¿¡.....
	// ...........
?>
</code>

µð¹ö±ë °ªÀ» ¾ò±âÀ§ÇØ PHP ¼Ò½ºÄÚµå ÆÄÀÏ¿¡ debug2_() ¶õ È£ÃâÀ» ¾Æ·¡¿Í 
°°ÀÌ ³Ö¾î¶ó
<code>
<?php
include ("debug2.inc");
debug2_(__FILE__, __LINE__, "f_somevariable", $f_somevariable);

function aa()
{
	$aa = 8;
	debug2_(__FILE__, __LINE__, "aa", $aa);
}
?>
</code>

PHP ÇÁ·Î±×·¥À» ½ÇÇàÇÏ°Ô µÇ¸é, °á°ú°¡ debug.out À̶õ È­ÀÏ¿¡ ÆÄÀÏÀ̸§, 
¶óÀιøÈ£, º¯¼ö¸í °ú º¯¼ö°ªÀÌ ³ªÅ¸³­´Ù. 

ÀϹøÀûÀ¸·Î debug2_()¸¦ »ç¿ëÇ϶ó. ÇÁ·Î±×·¥¿¡¼­ debug2_()ÀÇ È£ÃâÀº 
ÃÖÁ¾°á°ú Äڵ忡 ¾î¶°ÇÑ ¿µÇâµµ ÁÖÁö¾ÊÀ¸¸ç ½ÇÇà¿¡µµ ¾Æ¹«·± ¿µÇâÀ» 
ÁÖÁö¾Ê´Â´Ù. ¿Ö³ÄÇÏ¸é ¾Æ·¡¿¡ ±â¼úÇÑ°Í °°ÀÌ ÇÊÅ͸µ µÇ±â ¶§¹®ÀÌ´Ù.
debug2_()¸¦ ŸÀÌÇÎÇÏ´Â ½Ã°£À» ÁÙÀ̱â À§ÇØ º¹»ç(copy)¿Í ºÙ¿©³Ö±â(paste)¸¦ 
»ç¿ëÇÒ¼ö ÀÖ´Ù. ¶ÇÇÑ Vi ¿¡µðÅÍÀÇ 'yank to buffer' ±â´ÉÀ» ÀÌ¿ëÇØ¼­ º¹»çÇ϶ó.

°³¹ßÀÌ ¿Ï·áµÇ¸é Å×½ºÆ®ÇÏ°í ¼­¹ö¿¡ ¿Ã¸° Áغñ°¡ µÆÀ¸¸é ¼Ò½ºÄڵ忡¼­ 
debug2_ È£ÃâÀ» ÇÊÅ͸µ Ç϶ó. À¯´Ð½º ÇÁ·ÒÇÁÆ®¿¡¼­ -
<code>
bash$ mkdir production
bash$ grep -v debug2_  filea.php3 > production/filea.php3
</code>
¿©·¯°³ÀÇ È­ÀÏÀÌ ÀÖÀ¸¸é -
<code>
bash$ mkdir production
bash$ ls *.php3 | while read ans 
do 
	grep -v  debug2_ $ans > production/$ans
done
</code>
±×¸®°í ÀÌÁ¦ production ¿¡¼­ °³¹ßÇϴ°÷(¿µ¿ª)À» º¹»çÇ϶ó.
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt change> PHPÀÇ Á¦ÇÑ
-->
<sect> PHPÀÇ Á¦ÇÑ
<p>
¸ðµç »ç¶÷ÀÌ ÇѰè¿Í ´ÜÁ¡ÀÌ ÀÖµíÀÌ PHPµµ ¿¹¿Ü°¡ ¾Æ´Ï´Ù.
¾Æ·¡¿¡ Àִ°ÍÀº PHPÀÇ Á¦¾à(ÇѰè)ÀÌ´Ù.(±×·¡¼­ <bf>°æ°íÇÑ´Ù !!</bf>)
<enum>
<item> PHP´Â 100% ¼ø¼öÇÑ °´Ã¼ÁöÇâ ½ºÅ©¸³Æ® ¾ð¾î°¡ ¾Æ´Ï´Ù.
PHP´Â ÄÚµåÀÇ Å©±â°¡ 300,000 ¶óÀÎÀ» ³ÑÁö ¾ÊÀ¸¸é ±¦Âù´Ù.
300,000 ¶óÀÎÀÌ ³Ñ´Â PHPÄڵ带 °ü¸®Çϱâ´Â Á»´õ Èûµé¾îÁú°ÍÀÌ´Ù.
<item> PHP´Â "C"³ª "C++" ¾ð¾îÀÇ ¼º´ÉÀ» ÁÖÁö ¸ðÇÑ´Ù. ¿Ö³ÄÇϸé
PHP´Â ½ºÅ©¸³Æ® ¾ð¾îÀÌ°í ½ÇÇà¹æ½ÄÀÌ ÀÎÅÍÇÁ¸®ÅÍ Çü½ÄÀ̱⠶§¹®¿¡ ÃÖÀûÈ­µÈ 
"C++"º¸´Ù ´Ù¼Ò ´À¸®´Ù.
ÃÖ°íÀÇ ¼º´ÉÀ» ¿øÇÑ´Ù¸é "C++"°ú Ä¿³Ø¼Ç Ç®¸µ(connection pooling)µÈ 
µ¥ÀÌŸº£À̽º/¿û¼­¹ö¿Í ¿¬µ¿µÈ ºü¸¥ CGI ¸¦ »ç¿ëÇϰí C++ ÄÄÆÄÀÏ·¯ ¿ÉƼ¸¶ÀÌÁ®¸¦
"-03" ¿É¼ÇÀ» »ç¿ëÇ϶ó.
PHP 4¿¡ ÀÖ´ÂÁ¨µå¿ÉƼ¸¶ÀÌÁ®´Â PHPÀÇ ¼º´ÉÀ» ¾î´ÀÁ¤µµ Çâ»ó½Ãų°ÍÀÌ´Ù.
</enum>

ÇÑÆíÀ¸·Î´Â PHP´Â ¸¹Àº ÀåÁ¡À» °¡Áö°í ±× ÀåÁ¡Àº Á¦ÇÑÀ» º¸ÃæÇÒ¼ö ÀÖ´Ù -
<enum>
<item> PHP ½ºÅ©¸³Æ® ¾ð¾î¿¡¼­´Â ÄÄÆÄÀϰú ¸µÅ©°¡ »ý·«µÇ±â ¶§¹®¿¡ ¸Å¿ì ºü¸£°Ô
À¥¾îÇø®ÄÉÀ̼ÇÀ» °³¹ßÇÒ¼öÀÖ´Ù.
<item> PHP ¿¡Çø®ÄÉÀ̼ÇÀº ¸Å¿ì ¾ÈÁ¤ÀûÀ̰í ÀÚ¹Ù½ºÅ©¸³Æ®°¡ ºê¶ó¿ìÁ®¿¡ ÀÇÁ¸ÀûÀΰͰú 
´Ù¸£°Ô ºê¶ó¾ÆÁ®ÀÇ ±â¼ú¿¡ ÀÇÁ¸ÀûÀÌÁö ¾Ê´Ù.
PHP´Â ¾î¶² ¼­¹ö Ç÷¿Æû°ú ¾î¶² ºê¶ó¿ìÁ®¸¦ ¼±ÅÃÇØ¾ßÇÏ´Â °Í¿¡ ´ëÇÑ ÀÚÀ¯¸¦ ÁÖ°í
ºê¶ó¿ìÁ®´Â HTML ÀÌ PHP°¡ ¸¸µé¾î³Â´Ù´Â °ÍÀ» ¸ð¸¥´Ù!
<item> PHP´Â ¸ðµç SQL Å×ÀÌÅͺ£À̽º ¼­¹ö¿ÍÀÇ ¿¬°á¼ºÀÌ ¶Ù¾î³ª´Ù.
<item> PHP´Â ºÎºÐÀûÀ¸·Î °´Ã¼ÁöÇâ Æ¯¼ºÀ» °¡Áö°í ÀÖ´Ù.
<item> PHP´Â "C++", Perl, Javascript¿Í ºñ½ÁÇÑ ¹®¹ýÀ» °¡Áö°í ¼Ò½ºÄڵ带 Ž»öÇÒ¼ö ÀÖ´Â
ÇÁ·Î±×·¥°ú ºñ½ÁÇÑ 'ptags/ctags'¸¦ °¡Áö°í ÀÖ´Ù.
<item> PHP´Â ¼Óµµ¸¦ Çâ»ó½Ãų¼ö ÀÖ´Â Á¨µå¿ÉƼ¸¶ÀÌÁ®¸¦ °¡Áö°í ÀÖ´Ù.
<item> PHP´Â ¸ðµç À¯´Ð½ºµé, ¸®´ª½º, À©µµ 95/NT/200 ¿¡¼­ ½ÇÇàµÇ¸ç 
ASP, JSP¿Í ´Ù¸¥°Íº¸´Ù ¼º´ÉÀÌ ÁÁ´Ù.
<item> PHP´Â ¸¹Àº »ç¿ëÀÚÃþ¿Í °³¹ßÀÚÃþÀ» °¡Áö°í ÀÖ´Ù.
</enum>

<bf>°æ°í: </bf> ¸¸¾à 100% ¼ø¼öÇÑ °´Ã¼ÁöÇâ ½ºÅ©¸³Æ® ¾ð¾î¸¦ ¿øÇÑ´Ù¸é "¹Ýµå½Ã" 
<bf>Python</bf>À» ¿°µÎÇØ¶ó. 'Python'Àº óÀ½ºÎÅÍ °´Ã¼ÁöÇâ ½ºÅ©¸³Æ®¾ð¾îÀÌ´Ù.
'Zope'¶ó°í ºÒ¸®´Â Python À¥ ¾îÇø®ÄÉÀÌ¼Ç ¼­¹ö¸¦ »ç¿ëÇÒ¼ö ÀÖ´Ù.
'Zope'´Â <url url="http://www.zope.org"> ¿¡¼­ ÀÖ°í pythonÀº 
<url url="http://www.python.org">¿¡ ÀÖ´Ù.
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt change> °ü°èÀÖ´Â  URLµé
-->
<sect> °ü°èÀÖ´Â  URLµé
<p>
C, C++¿¡ °ü°èÀÖ´Â ´ÙÀ½ Àå¼Ò¸¦ ¹æ¹®Ç϶ó -
<itemize>
<item> C++, CÀ» À§ÇÑ Ä÷¯ Vim ÅØ½ºÆ® ¿¡µðÅÍ <url url="http://metalab.unc.edu/LDP/HOWTO/Vim-HOWTO.html">
<item> PHP PostgreSQL¸¦ À§ÇÑ SQL database server<url url="http://metalab.unc.edu/LDP/HOWTO/PostgreSQL-HOWTO.html">
<item> C++ ÇÁ·Î±×·¥À» À§ÇÑ Source code control system CVS HOWTO<url url="http://metalab.unc.edu/LDP/HOWTO/CVS-HOWTO.html">
<item> Linux goodies main site <url url="http://www.aldev.8m.com">
<item> Linux goodies mirror site <url url="http://aldev.webjump.com">
</itemize>
<!-- 
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt change> À̹®¼­ÀÇ ´Ù¸¥ Æ÷¸ä
-->
<sect> À̹®¼­ÀÇ ´Ù¸¥ Æ÷¸ä
<p>
À̹®¼­´Â DVI, Postscript, Latex, Adobe Acrobat PDF, LyX, GNU-info, HTML, 
RTF(Rich Text Format), Plain-text, Unix man pages ¿Í SGML 11°¡ÁöÀÇ ´Ù¸¥ 
Æ÷¸äÀÌ ÀÖ´Ù.
<itemize>
<item>
ÀÌ HOWTO ¹®¼­À» HTML, DVI, Postscritp ¶Ç´Â SGML Æ÷¸äÀ¸·Î µÈ tar ball ÆÄÀÏÀ»
<url url="ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO/other-formats/"> ¿¡¼­ ±¸ÇÒ¼ö ÀÖ´Ù.

<item>´Ü¼øÇÑ ÅØ½ºÆ® Æ÷¸äÀº <url url="ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO">¿¡¼­

<item>ºÒ¾î, µ¶¾î, ¼­¹Ý¾Æ¾î, Áß±¹¾î, ÀϺ»¾î·Î ¹ø¿ªµÈ ¹®¼­´Â
<url url="ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO"> ¿¡¼­ ±¸ÇÒ¼ö ÀÖ´Ù.
´Ù¸¥ ¾ð¾î·Î ¹ø¿ªÇÏ½Ç ºÐÀÇ µµ¿òÀ» ȯ¿µÇÑ´Ù.
</itemize>
À̹®¼­´Â <url url="http://www.sgmltools.org">¿¡¼­ ±¸ÇÒ¼ö ÀÖ´Â "SGML-Tools"¶õ ÅøÀ» 
»ç¿ëÇØ¼­ ÀÛ¼ºµÇ¾ú´Ù.
´ÙÀ½°ú °°Àº  ¸í·ÉÀ» »ç¿ëÇØ¼­ ¼Ò½º¸¦ ÄÄÆÄÀÏ ÇÒ¼ö ÀÖ´Ù.
<itemize>
<item>sgml2html CVS-HOWTO.sgml     (html È­ÀÏÀ» ¸¸µé±â À§ÇØ)
<item>sgml2rtf  CVS-HOWTO.sgml     (RTF È­ÀÏÀ» ¸¸µé±â À§ÇØ)
<item>sgml2latex CVS-HOWTO.sgml    (latex È­ÀÏÀ» ¸¸µé±â À§ÇØ)
</itemize>

LaTex ¹®¼­´Â <bf>sgml2latex</bf> (¿Í dvips) ±×¸®°í ¾ÆÅ©·Î¹ÙÆ®(Acrobat) <bf>distill</bf> 
(<url url="http://www.adobe.com">) À» »ç¿ëÇÑ Æ÷½ºÆ®½ºÅ©¸³Æ® °á°ú 󸮷ΠPDFÈ­ÀÏ·Î ½±°Ô ¹Ù²Ü¼ö ÀÖ´Ù.
´ÙÀ½À½ ¸í·ÉµéÀÌ´Ù:
<code>
bash$ man sgml2latex
bash$ sgml2latex filename.sgml
bash$ man dvips
bash$ dvips -o filename.ps filename.dvi
bash$ distill filename.ps
bash$ man ghostscript
bash$ man ps2pdf
bash$ ps2pdf input.ps output.pdf
bash$ acroread output.pdf &
</code>
¶Ç´Â °í½ºÆ®½ºÅ©¸³(Ghostscript) ¸í·É <bf>ps2pdf</bf>À» »ç¿ëÇÒ¼ö ÀÖ´Ù.
ps2pdf´Â Adobe's Acrobat Distiller product ÀÇ °ÅÀÇ ¸ðµç ±â´É°ú ºñ½ÁÇÏ°Ô 
µ¿ÀÛÇÑ´Ù. Æ÷½ºÆ®½ºÅ©¸³Æ® È­ÀÏÀ» PDF(Portable Document Format)À¸·Î ¹Ù²Ù¾îÁØ´Ù.
<bf>ps2pdf</bf>´Â ¸í·É ½ºÅ©¸³Æ®(command script/¹èÄ¡ÆÄÀÏ)°¡ Ghostscript¸¦ 
ºÒ·¯³»°í , <bf>pdfwrite</bf>¶ó°í ºÒ¸®´Â Ưº°ÇÑ Ãâ·Â µð¹ÙÀ̽º¸¦ ¼±ÅÃÇÏ¿©
½ÇÇàµÈ´Ù. ps2pdf¸¦ »ç¿ëÇϱâ À§ÇØ Ghostscript¸¦ ÄÄÆÄÀÏ ÇÒ¶§ 
pdfwrite ÀåÄ¡°¡ makefile¿¡ Æ÷ÇԵǾî¾ßÇÑ´Ù;
ÀÚ¼¼ÇÑ °ÍÀº Ghostscript ¼³Ä¡ ¹®¼­¸¦ º¸¾Æ¶ó.


À̹®¼­´Â ´ÙÀ½¿¡¼­ ãÀ»¼ö ÀÖ´Ù -
<itemize>
<item> <url url="http://sunsite.unc.edu/LDP/HOWTO/CVS-HOWTO.html">
</itemize>

¶ÇÇÑ ´ÙÀ½ÀÇ ¹Ì·¯ »çÀÌÆ®¿¡¼­ À̹®¼­¸¦ ãÀ»¼ö ÀÖ´Ù -
<itemize>
<item> <url url="http://www.caldera.com/LDP/HOWTO/CVS-HOWTO.html">
<item> <url url="http://www.WGS.com/LDP/HOWTO/CVS-HOWTO.html">
<item> <url url="http://www.cc.gatech.edu/linux/LDP/HOWTO/CVS-HOWTO.html">
<item> <url url="http://www.redhat.com/linux-info/ldp/HOWTO/CVS-HOWTO.html">

<item> ´Ù¸¥ ´ç½Å°ú °¡±î¿î ¹Ì·¯»çÀÌÆ®(network-address-wise)´Â 
<url url="http://sunsite.unc.edu/LDP/hmirrors.html">¿¡¼­ ãÀ»¼ö ÀÖ´Ù.
»çÀÌÆ®¸¦ ¼±ÅÃÇϰí /LDP/HOWTO/CVS-HOWTO.html µð·ºÅ丮°í °¡¶ó.
</itemize>


±× dvi Æ÷¸äÀ¸·Î µÇ¾îÀÖ´Â ±× ¹®¼­¸¦ º¸±âÀ§Çؼ­´Â xdvi¶õ ÇÁ·Î±×·¥À» »ç¿ëÇ϶ó.
xdvi ÇÁ·Î±×·¥Àº ·¡µåÇÞ ¸®´ª½ºÀÇ tetex-xdvi*.rpm ÆÐŰÁö¿¡ ÀÖ°í 
¸Þ´º¹öư ControlPanel | Applications | Publishing | TeX ¿¡ ÀÖ´Ù.
	dvi ¹®¼­¸¦ Àбâ À§ÇØ ´ÙÀ½ÀÇ ¸í·ÉÀ» ½ÇÇàÇ϶ó -
<tscreen><verb>
	xdvi -geometry 80x90 howto.dvi
	man xdvi
</verb></tscreen>
	±×¸®°í ¸¶¿ì½º¸¦ »ç¿ëÇÏ¿© À©µµ¿ì Å©±â¸¦ Á¶ÀýÇ϶ó.
	È­»ìǥŰ, Page Up, Page Down keys ¿Í
	'f', 'd', 'u', 'c', 'l', 'r', 'p', 'n' ¸¦ ÀÌ¿ëÇÏ¿©
	À§, ¾Æ·¡, Áß°£, ´ÙÀ½ÆäÀÌÁö, Àü ÆäÀÌÁö µîÀ» Ž»öÇÒ¼ö ÀÖ´Ù.
	½ÇÇàÀ» ³¡³»·Á¸é 'x'¸¦ ´­·¯¶ó.

'gv'(ghostview)³ª 'ghostscript'¶õ ÇÁ·Î±×·¥À» »ç¿ëÇØ¼­ Æ÷½ºÆ®½ºÅ©¸³Æ®
È­ÀÏÀ» ÀÐÀ»¼ö ÀÖ´Ù.
·¡µåÇÞ ¸®´ª½º¿¡¼­ ghostscript ´Â ghostscript*.rpm ÆÐŰÁö¿¡
gv´Â gv*.rpm ÆÐŰÁö¿¡ ÀÖ´Ù. ±×¸®°í ControlPanel | Applications | Graphics
¸Þ´º ¹öư¿¡ À§Ä¡ÇÑ´Ù. gv °¡ ghostscriptº¸´Ù ´õ Ä£±ÙÇÑ ÇÁ·Î±×·¥ÀÌ´Ù.
±×¸®°í ghostscript¿Í gv´Â OS/2, Windows 95 ¿Í NT ¿ëµµ Á¸ÀçÇÑ´Ù. ±×¸®°í
±× ¿î¿ëüÁ¦¿¡¼­ ÀÌ ¹®¼­µµ º¼¼ö ÀÖ´Ù. 
 
<itemize>
<item>Get ghostscript for Windows 95, OS/2, and for all OSes from <url url="http://www.cs.wisc.edu/~ghost">
</itemize>

Æ÷½ºÆ®½ºÅ©¸³Æ® ¹®¼­¸¦ Àбâ À§ÇØ ´ÙÀ½À» ÀÔ·ÂÇ϶ó -
<tscreen><verb>
		gv howto.ps
		ghostscript howto.ps
</verb></tscreen>

³×½ºÄÉÀÌÇÁ ³×ºñ°ÔÀÌÅÍ, ¸¶ÀÌÅ©·Î¼ÒÇÁÆ® ÀÎÅÍ³Ý ÀͽºÆú·Î·¯, ·¡µåÇÞ ¹Ù·Ð À¥ºê¶ó¿ìÁ® 
¶Ç´Â 10°¡Áö ÀÌ»óÀÇ À¥ºÎ¶ó¿ìÁ®¿¡¼­ HTML Æ÷¸Ë¹®¼­¸¦ ÀÐÀ»¼ö ÀÖ´Ù.

LyX ¶ó´Â X-Windows¿ë ÇÁ·Î±×·¥À¸·Î latex ¹®¼­¸¦ ÀÐÀ»¼ö ÀÖ´Ù.
<!-- 
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt> ÀúÀÛ±Ç
-->
<sect> ÀúÀÛ±Ç
<p>

ÀúÀÛ±ÇÁ¤Ã¥Àº LDP(¸®´ª½º ¹®¼­ ÇÁ·ÎÁ§Æ®)ÀÇ GNU/GPLÀ» µû¸¥´Ù.
LDP´Â GNU/GPL ÇÁ·ÎÁ§Æ®ÀÌ´Ù.
Ãß°¡ÀûÀÎ ¿ä±¸ - ÀúÀÛÀÚÀÇ À̸§, À̸ÞÀÏÁÖ¼Ò¿Í ÀÌ ÀúÀ۱ǻçÇ×À» À¯ÁöÇ϶ó.
¸¸¾à ´ç½ÅÀÌ À̹®¼­¿¡ ¾î¶°ÇÑ ¼öÁ¤À̳ª ÷°¡¸¦ ÇÒ°æ¿ì À̹®¼­ÀÇ ÀúÀÚ¿¡°Ô ¾Ë·ÁÁÖ¾î¶ó.
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt> ºÎ·Ï A  Database Wrapper ¿¹Á¦ <label id="Appendix A">
-->
<sect> ºÎ·Ï A Database Wrapper ¿¹Á¦ <label id="Appendix A">
<p>
Á¦ÃâÀÚ : Barton Greg 
       <htmlurl url="mailto:
			greg@createtech.com
			" name="
			greg@createtech.com
		">
ÀÌÈ­ÀÏÀ» ¾òÀ¸·Á¸é À¥ºê¶ó¿ìÁ®¿¡¼­ '´Ù¸¥À̸§À¸·Î ÀúÀå'À» ´©¸£°í 
pgsql.lib ¶ó°í ÀÔ·ÂÇϽÿÀ.
<code>
À̰ÍÀº PostgresSQLÀ» À§ÇÑ µ¥ÀÌÅͺ£À̽º ·¦ÆÛÀÌÁö¸¸ ´Ù¸¥ Çü½ÄÀÇ
µ¥ÀÌÅͺ£À̽º¸¦ À§ÇØ Á¶±Ý¸¸ °íÄ¡¸é »ç¿ëÇÒ¼ö ÀÖ´Ù.


<?php

if ($dbObjDefined  !=  1)
{
	$dbObjDefined  =  1;

	// Wrapper  class  for  database  calls
	class  dbObj
	{
		// Connection  handle  to  database
		var  $conn;

		// Default  connection  parameters
		var  $host  =  "YourSite.com";
		var  $user  =  "johndoe";
		var  $password  =  "pwd";
		var  $port  =  "5432";
		var  $dbname  =  "MyDB";

		// Open  initial  connection.  $params  is  
		// an  associative  array  holding
		// parameters  to  the  pg_Connect  function.
		function  init($params)
		{
			if(isset($parame[host]))
				$host  =  $parame[host];
			else
				$host  =  $this->host;

			if(isset($parame[user]))
				$user  =  $parame[user];
			else
				$user  =  $this->user;

			if(isset($parame[password]))
				$password  =  $parame[password];
			else
				$password  =  $this->password;

			if(isset($parame[port]))
				$port  =  $parame[port];
			else
				$port  =  $this->port;

			if(isset($parame[dbname]))
				$dbname  =  $parame[dbname];
			else
				$dbname  =  $this->dbname;

			$this->conn  =  pg_Connect ( "  host=$host  user=$user  password=$password  port=$port  dbname=$dbname ");
		}

		// Send  SQL  to  database  connection.
		// Return  recordset  object  on  success.
		// Return  0  on  failure.
		function  exec($SQL)
		{
			$this->resultset  =  pg_Exec($this->conn,  $SQL);

			if  ($this->resultset)  
			{
				$recset  =  new  recordset;
				$recset->init($this->resultset);
				return  $recset;
			}
			else  
			{
				return  0;
			}
		}

		function valid()
		{
			return $this->resultset;
		}

		// Close  connection  to  database
		function  free()
		{
			pg_close($this->conn);
		}
	};

	/*
	** This  is  a  simple  recordset  class  which  can  be
	** traversed  using  next(),  prev(),  and  current()  methods.
	** It  is  initialized  from  a  resultset  returned  from  the
	** function  "pg_Exec"  or  can  be  generated  by  a  call  to  the
	** exec  method  from  the  dbObj class given above.
	** Below "Tuples" means rows.
	*/
	class  recordset
	{
		var  $resultset;
		var  $index;
		var  $numFields;
		var  $numTuples;

		function  init($newResultset)
		{
			$this->resultset  =  $newResultset;
			$this->index  =  0;
			$this->numFields  =  pg_NumFields($this->resultset);
			$this->numTuples  =  pg_NumRows($this->resultset);
		}

		// Used in display() below
		function valid()
		{
			return $this->resultset;
		}

		// Get  a  value  by  row  number  and  either  
		// column  name  or  column  number
		function  getVal($row,  $col)
		{
			return  pg_Result($this->resultset,  $row,  $col);
		}

		// Return  an  array  of  field  names
		function  getFields()
		{
			for ($i=0;  $i < $this->numFields;  $i++)
				$retArray[] = pg_FieldName($this->resultset,  $i);
			return  $retArray;
		}

		// Get  number  of  columns  in  resultset
		function  getNumFields()
		{
			return  $this->numFields;
		}

		// Get  a  tuple  (associative  array  of  
		// column  values)  by  row  number
		function  getTupleDirect($row)
		{
			for ($i=0;  $i < $this->numFields;  $i++)
			{
				$retArray[pg_FieldName($this->resultset,  $i)]  = 
					pg_Result($this->resultset,  $row,  $i);
			}
			return  $retArray;
		}

		// Get  an  array  filled  with  all  values  in  a  column
		// (using  either  column  name  or  column  number)
		function  getColumn($col)
		{
			for ($i=0; $i < $this->numTuples; $i++)
				$retArray[]  =  pg_Result($this->resultset,  $i,  $col);
			return  $retArray;
		}

		// Return  the  number  of  records  in  the  recordset
		function  getNumTuples()
		{
			return  $this->numTuples;
		}

		// Get  tuple  pointed  to  by  the  current  index
		function  getTuple()
		{
			if ($this->index >= 0  &&  $this->index  <  $this->numTuples)
				return  $this->getTupleDirect($this->index);
			else
				return  0;
		}

		function valueof($col)
		{
			if ($col < $this->numFields)
			{
				return pg_Result($this->resultset,  $this->index,  $col);
			}
			else
			{
				return "";
			}
		}

		// Reached last row - end of rows ? Used in display() below
		function eof()
		{
			return $this->index == $this->numTuples;
		}

		// Return  1  if  index  is  within  bounds  of  the  recordset
		function  current()
		{
			if ($this->index >= 0  &&  $this->index  <  $this->numTuples)
				return  1;
			else
				return  0;
		}

		// Increment  index. Used in display() below
		function  next()
		{
			if ($this->index < $this->numTuples)
			{
				$this->index++;
				return  1;
			}
			else
			{
				return  0;
			}
		}

		// Decrement  index
		function  prev()
		{
			if ($this->index  >=  0)
			{
				$this->index--;
				return  1;
			}
			else
			{
				return  0;
			}
		}

		// Reset  index  to  0 - See also first()
		function  reset()
		{
			$this->index  =  0;
		}

		// See also reset(). Used in display() below
		function  first()  
		{
			$this->index  =  0;
		}

		function last()
		{
			$this->index = $this->numTuples -1 ;
		}

		// Used in display() below
		function showheader($col, $fmt = "")
		{
			printf("\t< th %s>%s< /th >\n", $fmt, 
			is_string($col) ? $col : pg_fieldname($this->resultset, $col));
		}

		// Used in display() below
		function showvalue($col, $fmt =  "", $def =  " ")
		{
			$v = $this->valueof($col);
			printf( "\t< td %s>%s< /td>\n", $fmt, $v ==  "" ? $def : $v);
		}

		function showurl($col, $fmt =  "")
		{
			$v = $this->valueof($col);
			if ( $v !=  "" ) 
			{
				printf("\t< td %s> < /td>\n", $fmt);
			}
			else 
			{
				printf( "\t< td %s>< a href=%s>%s< /a>< /td>\n", $fmt, $v, $v);
			}
		}

		function display()
		{
			if (!$this->valid() ) 
			{
				return;
			}

			printf( "<table cellspacing=1 cellpadding=1 border=1>\n");

			printf( "<tr>\n");
			for ($c = 0; $c < $this->cols; $c++ )
			{
				$this->showheader($c);
			}
			printf( "< /tr>\n");

			$this->first();
			while (!$this->eof())
			{
				printf( "<tr>\n");

				for ($c = 0; $c < $this->cols; $c++)
				{
					$this->showvalue($c);
				}

				printf( "< /tr>\n");
				$this->next();
			}
			printf("< /table\n");
		}

		// Free  memory  allocated  to  recordset.
		function  free()
		{
			pg_Freeresult($this->resultset);
		}
	};
}

?>

</code>
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt> ºÎ·Ï B  SQL abstraction Example <label id="Appendix B">
-->
<sect> ºÎ·Ï B SQL abstraction Example <label id="Appendix B">
<p>
Á¦ÃâÀÚ : 
Gianugo Rabellino 
       <htmlurl url="mailto:
			nemorino@opera.it
			" name="
			nemorino@opera.it
		">
ÀÌÈ­ÀÏÀ» ¾òÀ¸·Á¸é À¥ºê¶ó¿ìÁ®¿¡¼­ '´Ù¸¥À̸§À¸·Î ÀúÀå'À» ´©¸£°í 
sqlabst.lib ¶ó°í ÀÔ·ÂÇϽÿÀ.
<code>

PX: PHP Code Exchange
<?php

/*
*    SAL - SQL Abstraction Library
*           version 0.01
*/

/*
** Set the variable $dbtype to any of the following
** values: MySQL, mSQL, Postgres, ODBC before including this library
*/
// $dbtype = "MySQL"; 
// $dbtype = "mSQL"; 
// $dbtype = "PostgreSQL"; 
// $dbtype = "ODBC"; 

// SQL_connect($host, $user, $password, $db)
// returns the connection ID

function SQL_connect($host, $user, $password, $db)
{
	global $dbtype;

	switch ($dbtype) 
	{
		case  "MySQL":
			$conn=mysql_pconnect($host, $user, $password);
			mysql_select_db($db);
			return $conn;
			break;;

		case  "mSQL":
			$conn=msql_pconnect($host);
			msql_select_db($db);
			return $conn;
			break;;

		case  "PostgreSQL":
			$conn=pg_pconnect($host, "5432", "",$db);
			return $conn;
			break;;

		case  "ODBC":
			$conn=odbc_pconnect($db,$user,$password);
			return $conn;
			break;;

		default:
			$conn=mysql_pconnect($host, $user, $password);
			mysql_select_db($db);
			return $conn;
			break;;
	}
}

// SQL_query($host, $user, $password, $db)
// executes an SQL statement, returns a result identifier
function SQL_query($query, $id)
{
	global $dbtype;
	switch ($dbtype) 
	{
		case  "MySQL":
			$res=mysql_query($query, $id);
			return $res;
			break;;

		case  "mSQL":
			$res=msql_query($query, $id);
			return $res;
			break;;

		case  "PostgreSQL":
			$res=pg_exec($id,$query);
			return $res;
			break;;

		case  "ODBC":
			$rid=odbc_prepare($id,$query);
			$res=odbc_execute($rid);
			return $res;
			break;;

		default:
			$res=mysql_query($query, $id);
			return $res;
			break;;
	}
}

// SQL_num_rows($host, $user, $password, $db)
// given a result identifier, returns the number of affected rows
function SQL_num_rows($res)
{
	global $dbtype;

	switch ($dbtype) 
	{
		case  "MySQL":
			$rows=mysql_num_rows($res);
			return $rows;
			break;;

		case  "mSQL":
			$rows=msql_num_rows($res);
			return $rows;
			break;;

		case  "PostgreSQL":
			$rows=pg_numrows($res);
			return $rows;
			break;;

		case  "ODBC":
			$rows=odbc_num_rows($res);
			return $rows;
			break;;

		default:
			$rows=mysql_num_rows($res);
			return $rows;
			break;;
	}
}


// SQL_fetchrow($res,$row)
// given a result identifier, returns an array with the resulting row
// Needs also a row number for compatibility with PostgreSQL
function SQL_fetch_row($res, $nr)
{
	global $dbtype;

	switch ($dbtype) 
	{
		case  "MySQL":
			$row = array();
			$row = mysql_fetch_row($res);
			return $row;
			break;;

		case  "mSQL":
			$row = array();
			$row = msql_fetch_row($res);
			return $row;
			break;;

		case  "PostgreSQL":
			$row = array();
			$row = pg_fetch_row($res,$nr);
			return $row;
			break;;

		case  "ODBC":
			$row = array();
			$cols = odbc_fetch_into($res, $nr, &$row);
			return $row;
			break;;

		default:
			$row = array();
			$row = mysql_fetch_row($res);
			return $row;
			break;;
	}
}

// SQL_fetch_array($res,$row)
// given a result identifier, returns an associative array
// with the resulting row using field names as keys.
// Needs also a row number for compatibility with PostgreSQL.
function SQL_fetch_array($res, $nr)
{
	global $dbtype;

	switch ($dbtype) 
	{
		case  "MySQL":
			$row = array();
			$row = mysql_fetch_array($res);
			return $row;
			break;;

		case  "mSQL":
			$row = array();
			$row = msql_fetch_array($res);
			return $row;
			break;;

		case  "PostgreSQL":
			$row = array();
			$row = pg_fetch_array($res,$nr);
			return $row;
			break;;

		/*
		* ODBC doesn't have a native _fetch_array(), so we have to
		* use a trick. Beware: this might cause HUGE loads!
		*/

		case  "ODBC":
			$row = array();
			$result = array();
			$result = odbc_fetch_row($res, $nr);
			$nf = count($result)+2;  /* Field numbering starts at 1 */
			for ($count=1; $count < $nf; $count++) 
			{
				$field_name = odbc_field_name($res, $count);
				$field_value = odbc_result($res, $field_name);
				$row[$field_name] = $field_value;
			}
			return $row;
			break;;
	}
}

</code>
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt> ºÎ·Ï C  PostgreSQL large object ¿¹Á¦ <label id="Appendix C">
-->
<sect> ºÎ·Ï C PostgreSQL large object ¿¹Á¦ <label id="Appendix C">
<p>
Á¦ÃâÀÚ : 
PHP code exchange 
       <htmlurl url="mailto:
px@sklar.com
			" name="
px@sklar.com
		">
ÀÌÈ­ÀÏÀ» ¾òÀ¸·Á¸é À¥ºê¶ó¿ìÁ®¿¡¼­ '´Ù¸¥À̸§À¸·Î ÀúÀå'À» ´­·¯ 
pgsql_largeobj.lib ¶ó°í ÀÔ·ÂÇϽÿÀ.
<code>

PX: PHP Code Exchange - PostgreSQL large object access

<?
	$database = pg_Connect ( "",  "",  "",  "",  "jacarta");
	pg_exec ($database,  "BEGIN");
	$oid = pg_locreate ($database);
	echo ( "$oid\n");
	$handle = pg_loopen ($database, $oid,  "w");
	echo ( "$handle\n");
	pg_lowrite ($handle,  "foo");
	pg_loclose ($handle);
	pg_exec ($database,  "COMMIT");
	pg_close ($database);
?>
</code>
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt> ºÎ·Ï D »ç¿ëÀÚ ÀÎÁõ ¿¹Á¦ <label id="Appendix D">
-->
<sect> ºÎ·Ï D »ç¿ëÀÚ ÀÎÁõ ¿¹Á¦ <label id="Appendix D">
<p>
ÀÌÈ­ÀÏÀ» ¾òÀ¸·Á¸é À¥ºê¶ó¿ìÁ®¿¡¼­ '´Ù¸¥À̸§À¸·Î ÀúÀå'À» ´©¸£°í 
user_pw.lib ¶ó°í ÀÔ·ÂÇϽÿÀ.

PHP 3 ¸Þ´º¾ó¿¡¼­ :
PHP°¡ ¾ÆÆÄÄ¡ ¸ðµâÀ϶§¸¸ ÀÛµ¿ÇÑ´Ù.
$PHP_AUTH_USER ¿Í $PHP_AUTH_PW ¸¦ Ãâ·ÂÇÏ´Â ´ë½Å, »ç¿ëÀÚÀ̸§°ú ºñ¹Ð¹øÈ£¸¦
È®Àθ¸ ÇϱâÀ» ¿øÇÒÁöµµ ¸ð¸¥´Ù. ¾Æ¸¶µµ µ¥ÀÌÅͺ£À̽º¿¡ Äõ¸®¸¦ º¸³»°Å³ª adm 
È­ÀÏ¿¡¼­ ã¾Æº¸¸é µÉ°ÍÀÌ´Ù.

<code>
<?php
	if (!$PHP_AUTH_USER)
	{
		Header("WWW-authenticate: basic realm=\"My Realm\"");
		Header("HTTP/1.0 401 Unauthorized");
		echo "Text to send if user hits Cancel button\n";
		exit;
	}
	else
	{
		echo "Hello $PHP_AUTH_USER.<P>";
		echo "You entered $PHP_AUTH_PW as your password.<P>";
	}
?>
</code>
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt> ºÎ·Ï E  ³×Æ®¿öÅ© °ü¸® ¿¹Á¦ <label id="Appendix E">
-->
<sect> ºÎ·Ï E ³×Æ®¿öÅ© °ü¸® ¿¹Á¦ <label id="Appendix E">
<p>
ÀÌ È­ÀÏÀ» ¾òÀ¸·Á¸é À¥ºê¶ó¿ìÀú¿¡¼­ network.lib¶õ À̸§ÀÇ 'ÅØ½ºÆ®(Text)' ÇüÅ·ΠÀúÀåÇ϶ó.

PHP: network adminstrator's best friend from <url url="http://www.phpWizard.net">

À¥°³¹ßÀڷμ­ ¾Æ¸¶ ping, whois, nslookup µîµîÀÇ À¯¿ëÇÑ ÅøÀ» »ç¿ëÇÒ°ÍÀÌ´Ù. ±×·¯³ª
°í°´ÀÇ »ç¹«½Ç¿¡¼­ ±× ÅøÁß Çϳª¸¦ »ç¿ëÇØ¾ßµÇ´Âµ¥ telnetÀ» »ç¿ëÇÒ¼ö ¾ø´Ù¸é ¾î¶»°ÔÇÒ°ÍÀΰ¡?
PHP ¸Å´º¾óÀÇ '³×Æ®¿öÅ©'¿¡¼­ functionÀ» ã¾Æº¸´Â °ÍÀÌ ´ë¾ÈÀÌ´Ù.

<bf>¼ÒÄÏ ÀÛµ¿ : </bf>

°¡Àå Áß¿äÇÑ ÇÔ¼ö´Â fsockopen()ÀÌ´Ù. ÀÌÇÔ¼ö¸¦ »ç¿ëÇÏ¸é ¼­¹öÀÇ ¿­·ÁÁø ¾î¶² 
Æ÷Æ®·Îµµ Á¢¼ÓÇÒ¼ö ÀÖ°í ¼ÒÄÏÀÇ ¿¬°áÀ» ¼³Á¤ÇÒ¼ö ÀÖ´Ù. ÇÔ¼öÀÇ ¹®¹ýÀº ´ÙÀ½°ú °°´Ù : 
<code>
	int fsockopen(string hostname, int port, int [errno], string [errstr]);
</code>
¾ÕÀÇ 2°³ÀÇ º¯¼ö´Â ½±°Ô ¾Ë¼ö ÀÖ°í, ´ÙÀ½ÀÇ 2°³ÀÇ º¯¼ö´Â ¿É¼ÇÀ̰í, ¿¡·¯¸¦ ó¸®Çϱâ
À§ÇØ ¾²ÀδÙ. "errno"°ú "errstr"Àº ÂüÁ¶¸¦ ÅëÇØ¼­ ÀÌ·ç¾îÁ®¾ß ÇÑ´Ù.
"ÂüÁ¶¸¦ ÅëÇØ ÀÌ·ç¾îÁø´Ù"´Â ¸»ÀÇ Àǹ̴ ¿ø·¡ÀÇ º¯¼ö°¡ º¯ÇÑ´Ù´Â ¸»ÀÌ´Ù.
º¸Åë, ÇÔ¼ö°¡ ½ÇÇàµÇ´õ¶óµµ º¯¼öÀÇ ³»¿ëÀº º¯ÇÏÁö ¾Ê´Â´Ù.

±×·¡¼­, À¥¼­¹ö¿¡ ¿¬°áÇϱâ À§ÇØ ÀÌÇÔ¼ö¸¦ »ç¿ëÇϰí Çì´õ¸¦ ÇÁ¸°Æ®Ç϶ó :
<code>
function get_headers($host, $path = "/")
{
	$fp = fsockopen ("$host", 80, &$errnr, &$errstr) or die("$errno: $errstr");
	fputs($fp,"GET $path HTTP/1.0\n\n");
	while (!$end)
	{
		$line = fgets($fp, 2048);
		if (trim($line) == "")
			$end = true;
		else
			echo $line;
	}
	fclose($fp);
}
</code>
ÀÌ ¿¹Á¦¿¡¼­´Â fsockopen()À» È£ÃâÇØ¼­ ¾òÀº ÆÄÀÏÆ÷ÀÎÅÍ¿Í ÆÄÀÏ󸮿¡ 
°üÇÑÀÀ¿ëÀ» ¾Ë¾Æº¼°ÍÀÌ´Ù.(fred, fwrite µîµî) 
HTTP/1.0 Ŭ¶óÀÌ¾ðÆ®¿¡¼­¸¸ ±¸ÇöµÈ´Ù´Â°ÍÀ» ¸í½ÉÇ϶ó. 
- name-based °¡»óÈ£½ºÆ®¿¡¼­´Â µ¿ÀÛÇÏÁö ¾Ê´Â´Ù.

<bf>Áö½Ã: </bf>

ÀϹÝÀûÀ¸·Î ´Ù¸¥ Æ÷Æ®·Î ¿¬°á ÇÒ¼ö ÀÖ´Ù. 
PHP·Î ÀÛÀº ÇΰŠŬ¶óÀÌ¾ðÆ®¸¦ ¸¸µç°ÍÀº ½¬°Ô ÇÒ¼ö ÀÖ´Ù.
ÇΰŠµ¥¸ó¿¡ Äõ¸®(Áú¹®)Çϱâ À§ÇØ ¾Æ·¡¿¡ ÀÖ´Â ¿¹Á¦¸¦ ¼öÁ¤Ç϶ó.
<code>
function finger ($host, $user)
{
	$fp = fsockopen($host, 79, &$errno, &$errstr) or die("$errno: $errstr");
	fputs($fp, "$user\n");
	while (!feof($fp))
		echo fgets($fp, 128);
	fclose($fp);
}
</code>

<bf>Whois: </bf>
ÈÄÀ̽º(whois) ¼­¹ö¿¡ Áú¹®Çϴ°͵µ °°Àº °³³äÀÌ´Ù:
<code>
// domain is like "phpwizard.net"
function whois($domain, $server="whois.internic.net")
{
	$fp = fsockopen ($server, 43, &$errnr, &$errstr) or die("$errno: $errstr");
	fputs($fp, "$domain\n");
	while (!feof($fp))
		echo fgets($fp, 2048);
	fclose($fp);
}
</code>

<bf>ºí·°Å·, ³Íºí·ÏÅ· Á¦¾î : </bf>
±×·¯³ª ÀÌÇÔ¼ö¸¦ »ç¿ëÇϴµ¥ ¹®Á¦°¡ ÀÖ´Ù. ´ÙÀ½°ú °°À»¶§¸¸ ÀßÀÛµ¿ÇÑ´Ù.
<enum>
<item> È£Ãâ½Ã°£ÀÌ ÀÛÀº ¿¬°áÀ϶§¿Í
<item> ¿¬°áÇϰí ÀÖ´Â ¼­¹ö°¡ »ì¾ÆÀÖ°í ÀÛµ¿ÇÒ¶§.
±×·¸Áö ¾ÊÀ¸¸é, ´ç½ÅÀÇ ½ºÅ©¸³Æ®´Â Á¾·áµÉ¶§±îÁö ÀÛµ¿ÇÑ´Ù. 
±×·¸°Ô µÇ´Â ÀÌÀ¯´Â ¼ÒÄÏ¿¬°áÀº ºí·°Å·µÇ¸ç Á¾·á°¡ µÇÁö¾Ê±â ¶§¹®ÀÌ´Ù.
set_socket_blocking()À̶õ ÇÔ¼ö´Â ´ÙÀ½°ú °°ÀÌ µ¿ÀÛÇÑ´Ù: ÇÔ¼ö´Â 
¸ðµçµ¿ÀÛÀ» ¼ÒÄÏ(ù¹øÂ° Àμö:¼ÒÄÏ Æ÷ÀÎÅÍ)¿¡ ºí·°Å·(µÎ¹øÀç Àμö:true)³ª
Æú½º(false)(¼¼¹øÂ° Àμö:false)·Î ¼³Á¤ÇÑ´Ù. ³Íºí·°Å·Á¦¾î¸¦ »ç¿ëÇϸé, 
ÇΰÅ(finger)ÇÔ¼ö´Â ´ÙÀ½°ú °°À»°ÍÀÌ´Ù:(¿ªÁÖ:¹«½¼¸»ÀÎÁö ¹ø¿ªÀÌ ÀÌ»óÇϳ׿ä)
</enum>

<code>
	$fp = fsockopen($host, 79, &$errno, &$errstr) or die("$errno: [ ] $errstr");
	set_socket_blocking($fp, 0);
	fputs($fp, "$user\n");

	$stop = time() + $timeout;
	while (!feof($fp) && time() < $stop )
		echo fgets($fp, 128);
	fclose($fp);
</code>
³Íºí·¯Å· ¼ÒÄÏÄÝ(socket calls)À» »ç¿ëÇϱâ À§ÇÑ 3°³ÀÇ ÇÔ¼öÀÇ ¼öÁ¤Àº ´ç½ÅÀÇ
¿¬½ÀÀ» À§ÇØ ³²°ÜµÐ´Ù.
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




<chapt> ºÎ·Ï F  Database Wrapper ¿¹Á¦ <label id="Appendix F">
-->
<sect> ºÎ·Ï F PostgreSQL Database Wrapper ¿¹Á¦ <label id="Appendix F">
<p>
Á¦ÃâÀÚ : Joe Thong
       <htmlurl url="mailto:
		   darkjoe@softhome.net
			" name="
		   darkjoe@softhome.net
		">
»çÀÌÆ® URL: <url url="http://phpdb.linuxbox.com">

<bf>¼³¸í: </bf> ¿©·¯°¡Áö µ¥ÀÌÅͺ£À̽º ¼­¹ö¿¡¼­ °á°ú Á¶ÀÛÀ» À§ÇÑ °­·ÂÇÑ 
PHP µ¥ÀÌŸº£À̽º ·¦ÆÛ.  µ¥ÀÌÅͺ£À̽ºÀÇ °á°ú°¡ phpDB¿¡ ÀÇÇØ ÀÚµ¿À¸·Î ³ª¿À°Ô µÈ´Ù.

ÀÌÈ­ÀÏÀ» ¾òÀ¸·Á¸é À¥ºê¶ó¿ìÁ®¿¡¼­ '´Ù¸¥À̸§À¸·Î ÀúÀå'À» ´©¸£°í 
phpDB-postgresql.lib ¶ó°í ÀÔ·ÂÇϽÿÀ.
<code>
<?php
/*
Name: phpDB PostgreSQL module
Version: 1.02bR6
Description: A PHP database wrapper for various database 
	servers with a powerful recordset for result data 
	manipulation.  Database results are flushed 
	automatically by phpDB.  
*/

/* define this module, to prevent double class declaration.	*/
if (!defined("_PHPDB_ABSTRACT_LAYER")) {
	define("_PHPDB_ABSTRACT_LAYER", 1 );
}
else
	return;

//---------------------------------------
	 Class Name: phpDB
//---------------------------------------
class phpDB 
{
	/*	public variables	*/
	var $version = '1.02bR6'; // Version number of phpDB
	// This variable keeps what database type is going to 
	// be used.  Current supported database server are 
	// MySQL, MSQL, SQL Server, and Sybase
	var $databaseType = '';
	// Specifies which database is going to be used
	var $databaseName = ''; 
	// The hostname of the database server, port 
	// number is optional.  e.g: "db.devNation.com"
	var $hostname = '';	
	var $username = ''; // used to connect to the database server
	var $password = ''; // Password for the username

	// Private variables ------ starts with underscore
	// An array of executed querys. For results cleanup purposes.
	var $_queryIDList = array();
	// The returned link identifier whenever a 
	// successful database connection is made
	var $_connectionID	= -1;	
	// A variable which was used to keep the returned 
	// last error message.  The value will then returned 
	// by the errorMsg() function
	var $_errorMsg = '';
						
	// This variable keeps the last created result 
	// link identifier
	var $_queryID = -1;	
	// A boolean variable to state whether its a persistent
	// connection or normal connection
	var	$_isPersistentConnection = false;
	// Holds the newly created result object, 
	// returned via the execute() method
	var $_tempResultObj = '';	

	// A constructor function for the phpDB object.  
	// When initializing, specify the dbType i.e: "mysql",
	// "msql", "postgresql", "mssql", and "sybase"
	function phpDB($dbType = "postgresql") 
	{
		switch ($dbType) {
			case "mysql":
			case "msql":
			case "postgresql":
			case "mssql":
			case "sybase":						
			case "informix":						
				$this->databaseType = $dbType;
				break;
			default:
				return false;
		}			
	}
	
	// Returns: A positive link identifier on success, or 
	// false on error. 	Connect to the server with the provided 
	// arguments. The connection to the server will be closed 
	// when the script terminates, unless close() function is 
	// called beforehand
	function connect($argHostname = "", $argUsername = "", 
		$argPassword = "", $argDatabaseName = "") 
	{
		$connString = "";
		$hostPieces = array();
		/*	Must specify the database argument	*/
		if (!$argDatabaseName) {	
			return false;
		}
		if ($argHostname != "") {
			$this->hostname = $argHostname;
		}
		if ($argUsername != "") {
			$this->username = $argUsername;
		}
		if ($argPassword != "") {
			$this->password = $argPassword;
		}
		if ($argDatabaseName != "") {
			$this->databaseName = $argDatabaseName;
		}				
		$hostPieces = split(":", $this->hostname);
		if ($hostPieces[0]) {
			$connString .= "host=$hostPieces[0]";
			if (isset($hostPieces[1])) {
				$connString .= " port=$hostPieces[1]";
			}			
		}
	    if ($this->username) {
			$connString .= " user=$this->username";
		}
	    if ($this->password) {
			$connString .= " password=$this->password";
		}
		$connString .= " dbname=$this->databaseName";
			
		$this->_connectionID = @pg_Connect($connString);
		return $this->_connectionID;
	}

	// Returns: A positive link identifier on success, or
	// false on error.  Connect to the server with the 
	// provided arguments. The connection to the server will 
	// not be closed when the script terminates. Instead it 
	// will be kept for later future use
	function pconnect($argHostname = "", $argUsername = "", 
		$argPassword = "", $argDatabaseName = "") 
	{
		$connString = "";
		$hostPieces = array();		
		/*	Must specify the database argument	*/
		if (!$argDatabaseName) {
			return false;
		}
		if ($argHostname != "") {
			$this->hostname = $argHostname;
		}
		if ($argUsername != "") {
			$this->username = $argUsername;
		}
		if ($argPassword != "") {
			$this->password = $argPassword;
		}
		if ($argDatabaseName != "") {
			$this->databaseName = $argDatabaseName;
		}				
		$hostPieces = split(":", $this->hostname);
		if ($hostPieces[0]) {
			$connString .= "host=$hostPieces[0]";
			if (isset($hostPieces[1])) {
				$connString .= " port=$hostPieces[1]";
			}			
		}
	    if ($this->username) {
			$connString .= " user=$this->username";
		}
	    if ($this->password) {
			$connString .= " password=$this->password";
		}
		$connString .= " dbname=$this->databaseName";
			
		$this->_connectionID = @pg_pConnect($connString);
		if ($this->_connectionID) {
			$this->_isPersistentConnection = true;				
		}
		return $this->_connectionID;
	}		
	
	// Returns: true on success, false on error Select 
	// the database name to be used PostgreSQL 
	// Note:	function Not available
	function selectDB($dbName) {
			return false;
	}

	// Returns: the Recordset object disregard success 
	// or failure Send the sql statement to the database server
	function execute($sql = "") {
		// Instantiate an object without considering whether 
		// the query return any results or not
		$this->_queryID = @pg_Exec($this->_connectionID, $sql);
		$this->_tempResultObj = new Recordset($this->_queryID);
		$this->_insertQuery($this->_queryID);
		return $this->_tempResultObj;
	}
	
	// Returns: the last error message from previous 
	// database operation
	function errorMsg() {
		$this->_errorMsg = @pg_errormessage($this->_connectionID);
	    return $this->_errorMsg;
	}

	// Returns: true on success, false on failure 
	// Close the database connection
	function close() {
		if ($this->_queryIDList && sizeof($this->_queryIDList > 0)) {
			while(list($_key, $_resultID) = each($this->_queryIDList)) {
				@pg_freeresult($_resultID);
			}
		}
		// If its not a persistent connection, then 
		// only the connection needs to be closed
		if ($this->_isPersistentConnection != true) {	
			return @pg_close($this->_connectionID);
		}
		else {
			return true;
		}
	}
	
	// A PRIVATE function used by the constructor function 
	// of the query object.  insert the successful returned
	// query id to the query id list.  Used for later results 
	// cleanup.  A private function that's never meant to 
	// be used directly
	function _insertQuery($query_id) {
		$this->_queryIDList[] = $query_id;
	}		
}
	
//------------------------------
	 Class Name: Recordset
//------------------------------
class Recordset 
{
	/*	public variables	*/
	var $fields;
	// indicates that the current record position is before 
	// the first record in a Recordset object
	var $BOF = null;

	// indicates that the current record position is after
	// the last record in a Recordset object
	var $EOF = null;	
	
	/*	private variables	*/
	var $_numOfRows = -1; // NEVER change the value! READ-ONLY!
	var $_numOfFields = -1;	// NEVER change the value! READ-ONLY!
	// Holds anything that was returned from the database specific functions
	var $_tempResult = ''; 
	// This variable keeps the result link identifier
	var $_queryID = -1;	
	// This variable keeps the current row in the Recordset
	var $_currentRow = -1;

	// Returns: query id on success and false if 
	// failed Constructor function
	function Recordset($queryID) 
	{
		$this->_queryID = $queryID;
		if ($queryID) {
			$this->_numOfRows = @pg_numrows($this->_queryID);
			/*	pg_numrows() returns -1 on error	*/
			if ($this->_numOfRows == -1) {
				$this->_numOfRows = 0;
			}
			$this->_numOfFields = @pg_numfields($this->_queryID);
			/*	pg_numfields() returns -1 on error	*/
			if ($this->_numOfFields == -1) {
				$this->_numOfFields = 0;
			}
		}
		else {
			$this->_numOfRows = 0;
			$this->_numOfFields = 0;
		}
		/*	If result set contains rows	*/
		if ($this->_numOfRows > 0 && $this->_currentRow == -1) {
			$this->_currentRow = 0;
			$this->fields = @pg_fetch_array($this->_queryID, $this->_currentRow);			
			$this->EOF = false;
			$this->BOF = false;
		}
 		return $this->_queryID;
	}
		
	// Returns: true if successful, false if fail Set the Recordset 
	// pointer to a specified field offset. If the next call to 
	// fetchField() won't include a field offset, this field would 
	// be returned.  PostgreSQL Note:	function Not available
	function fieldSeek($fieldOffset = -1) {
		$this->_tempResult = false;
		return $this->_tempResult;
	}

	// Returns: an object containing field information.  Get column 
	// information in the Recordset object. fetchField() can be used 
	// in order to obtain information about fields in a certain query 
	// result. If the field offset isn't specified, the next field 
	// that wasn't yet retrieved by fetchField() is retrieved. 
	// PostgreSQL Note:	function Not available
	function fetchField($fieldOffset = -1) {
		$this->_tempResult = false;		
		return $this->_tempResult;
	}				

	// Returns: true if there still rows available, or false if there 
	// are no more rows.  Moves to the next row in a specified Recordset 
	// object and makes that record the current row and the data 
	// corresponding to the row will be retrieved into the fields 
	// collection.  Note: Unlike the moveRow() method, when _currentRow
	// is getNumOfRows() - 1, EOF will immediately be true.  If row number
	// is not provided, the function will point to the 
	// first row automatically
	function nextRow() {
		if ($this->getNumOfRows() > 0) {			
			$this->fields = array();
			$this->_currentRow++;
			$this->fields = @pg_fetch_array($this->_queryID, $this->_currentRow);
			/*	This is not working.  True all the time	*/
			if ($this->fields) {
				$this->_checkAndChangeEOF($this->_currentRow - 1);
				return true;
			}
		}
		$this->EOF = true;
		return false;
	}	
			
	// Returns: true on success, false on failure moveRow() moves 
	// the internal row pointer of the Recordset object to point 
	// to the specified row number and the data corresponding to
	// the row will be retrieved into the fields collection.  If 
	// row number is not provided, the function will point to 
	// the first row automatically
	function moveRow($rowNumber = 0) {
		if ($rowNumber == 0) {
			return $this->firstRow();
		}
		else if ($rowNumber == ($this->getNumOfRows() - 1)) {
			return $this->lastRow();
		}
		if ($this->getNumOfRows() > 0 && $rowNumber < $this->getNumOfRows()) {	
			$this->fields = null;
			$this->_currentRow = $rowNumber;
			$this->fields = @pg_fetch_array($this->_queryID, $this->_currentRow);
			/*	This is not working.  True all the time	*/
			if ($this->fields) {
				// No need to call _checkAndChangeEOF() because 
				// the possibility of moving to the last row 
				// has been handled by the above code
				$this->EOF = false;
				return true;
			}
		}
		$this->EOF = true;
		return false;
	}

	// Returns: true on success, false on failure firstRow() 
	// moves the internal row pointer of the Recordset object
	// to the first row and the data corresponding to the row 
	// will be retrieved into the fields collection
	function firstRow() {
		if ($this->getNumOfRows() > 0) {
			$this->fields = array();
			$this->_currentRow = 0;
			$this->fields = @pg_fetch_array($this->_queryID, $this->_currentRow);
			$this->EOF = true;
			/*	This is not working.  True all the time	*/
			if ($this->fields) {
				return true;	
			}
		}
		$this->EOF = true;
		return false;		
	}

	// Returns: true on success, false on failure lastRow() 
	// moves the internal row pointer of the Recordset object 
	// to the last row and the data corresponding to the row 
	// will be retrieved into the fields collection
	function lastRow() {
		if ($this->getNumOfRows() > 0) {	
			$this->fields = array();	
			$num_of_rows = $this->getNumOfRows();
			/*	$num_of_rows decemented at above 	*/
			$this->_currentRow = --$num_of_rows;	
			$this->fields = @pg_fetch_array($this->_queryID, $this->_currentRow);
			/*	This is not working.  True all the time	*/
			if ($this->fields) {
				/*	Special case for making EOF false.	*/
				$this->EOF = false;	
				return true;
			}
		}
		$this->EOF = true;
		return false;
	}

	// close() only needs to be called if you are worried about 
	// using too much memory while your script is running. All 
	// associated result memory for the specified result identifier 
	// will automatically be freed
	function close() {
		$this->_tempResult = @pg_freeresult($this->_queryID);		
		return $this->_tempResult;
	}

	// Returns: the number of rows in a result set.  
	// Get number of rows in result
	function getNumOfRows() {
		return $this->_numOfRows;
	}

	// Returns: the number of fields in a result set.
	// Get number of fields in result
	function getNumOfFields() {
		return $this->_numOfFields;
	}       

	/*	Check and change the status of EOF.	*/		
	function _checkAndChangeEOF($currentRow) {
		if ($currentRow >= ($this->_numOfRows - 1)) {
			$this->EOF = true;
		}		
		else {
			$this->EOF = false;		
		}
	}
}
?>
</code>
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




-->
<sect> ºÎ·Ï G Microsoft SQL Server DB Wrapper ¿¹Á¦ <label id="mssql G">
<p>
Á¦ÃâÀÚ : Joe Thong
       <htmlurl url="mailto:
		   darkjoe@softhome.net
			" name="
		   darkjoe@softhome.net
		">
Site URL: <url url="http://phpdb.linuxbox.com">

<bf>¼³¸í: </bf> ¿©·¯°¡Áö µ¥ÀÌÅͺ£À̽º ¼­¹ö¿¡¼­ °á°ú Á¶ÀÛÀ» À§ÇÑ °­·ÂÇÑ 
PHP µ¥ÀÌŸº£À̽º ·¦ÆÛ.  µ¥ÀÌÅͺ£À̽ºÀÇ °á°ú°¡ phpDB¿¡ ÀÇÇØ ÀÚµ¿À¸·Î ³ª¿À°Ô µÈ´Ù.

ÀÌÈ­ÀÏÀ» ¾òÀ¸·Á¸é À¥ºê¶ó¿ìÁ®¿¡¼­ '´Ù¸¥À̸§À¸·Î ÀúÀå'À» ´©¸£°í 
phpDB-msql.lib ¶ó°í ÀÔ·ÂÇϽÿÀ.
<code>
<?php
/*
Name: phpDB Microsoft SQL Server module
Version: 1.02bR6
Description: A PHP database wrapper for various 
	database servers with a powerful
	Recordset for result data manipulation.  Database 
	results are flushed automatically by phpDB.  
*/
// Define this module, to prevent double class declaration
if (!defined("_PHPDB_ABSTRACT_LAYER")) 
{
	define("_PHPDB_ABSTRACT_LAYER", 1 );
}
else
	return;

//------------------------------
	 Class Name: phpDB
//------------------------------
class phpDB 
{
	// public variables
	var $version = '1.02bR6'; // Version number of phpDB

	// This variable keeps what database type is going 
	// to be used.  Current supported database server 
	// are MySQL, MSQL, SQL Server, PostgreSQL and Sybase
	var $databaseType = ''; 
	var $databaseName = ''; // Specifies which database is going to be used

	// The hostname of the database server, port 
	// number is optional.  e.g: "db.devNation.com"
	var $hostname = ''; 

	var $username = ''; // to connect to the database server
	var $password = '';	// Password for the username
	
	// Private variables ----- starts with underscore

	// An array of executed querys. For results cleanup purposes
	var $_queryIDList = array();

	// The returned link identifier whenever a 
	// successful database connection is made
	var $_connectionID	= -1;
		
	// A variable which was used to keep the returned last 
	// error message.  The value will then returned 
	// by the errorMsg() function
	var $_errorMsg = ''; 
	// This variable keeps the last created result link identifier
	var $_queryID = -1;	

	// A boolean variable to state whether its a 
	// persistent connection or normal connection
	var	$_isPersistentConnection = false;	
	
	// Holds the newly created result object, returned 
	// via the execute() method
	var $_tempResultObj = '';	

	//	A constructor function for the phpDB object.  
	// When initializing, specify the dbType i.e: "mysql",
	// "msql", "postgresql", "mssql", and "sybase"
	function phpDB($dbType = "mssql") 
	{
		switch ($dbType) 
		{
			case "mysql":
			case "msql":
			case "postgresql":
			case "mssql":
			case "sybase":						
			case "informix":						
				$this->databaseType = $dbType;
				break;
			default:
				return false;
		}
	}

	// Returns: A positive link identifier on success, 
	// or false on error. 	Connect to the server with 
	// the provided arguments. The connection to the server 
	// will be closed when the script terminates, unless 
	// close() function is called beforehand.
	function connect($argHostname = "", $argUsername = "", 
		$argPassword = "", $argDatabaseName = "") 
	{
		$boolDBSelected;
		if ($argHostname != "") {
			$this->hostname = $argHostname;
		}
		if ($argUsername != "") {
			$this->username = $argUsername;
		}
		if ($argPassword != "") {
			$this->password = $argPassword;
		}
		if ($argDatabaseName != "") {
			$this->databaseName = $argDatabaseName;
		}				
		
		$this->_connectionID = @mssql_connect($this->hostname, $this->username, $this->password);
		
		if ($this->databaseName && $this->_connectionID) {
			$boolDBSelected = @mssql_select_db($this->databaseName);
			if(!$boolDBSelected) {	/*	If DB selection fails	*/
				@mssql_close($this->_connectionID);	/*	Close the current connection	*/
				return false;	
			}
		}		
		return $this->_connectionID;
	}

	// Returns: A positive link identifier on success, or 
	// false on error Connect to the server with the provided
	// arguments. The connection to the server will not be closed 
	// when the script terminates. Instead it will be kept for 
	// later future use
	function pconnect($argHostname = "", $argUsername = "", 
		$argPassword = "", $argDatabaseName = "") 
	{
		$boolDBSelected;
		if ($argHostname != "") {
			$this->hostname = $argHostname;
		}
		if ($argUsername != "") {
			$this->username = $argUsername;
		}
		if ($argPassword != "") {
			$this->password = $argPassword;
		}
		if ($argDatabaseName != "") {
			$this->databaseName = $argDatabaseName;
		}				
		
		$this->_connectionID = @mssql_pconnect($this->hostname, $this->username, $this->password);
		if ($this->_connectionID) {
			$this->_isPersistentConnection = true;				
		}
		
		if ($this->databaseName && $this->_connectionID) {
			$boolDBSelected = @mssql_select_db($this->databaseName);
			if(!$boolDBSelected) {	/*	if DB selection fails	*/
				return false;	/*	Persistent connection can't be closed	*/
			}
		}		
		return $this->_connectionID;
	}
	
	//	Returns: true on success, false on error Select the 
	// database name to be used
	function selectDB($dbName) 
	{
		$this->databaseName = $dbName;
		if ($this->_connectionID) {
			return @mssql_select_db($dbName);		
		}
		else {
			/*	No database selected	*/
			return false;
		}			
	}

	// Returns: the Recordset object disregard success or 
	// failure Send the sql statement to the database server
	function execute($sql = "") 
	{
		$this->_queryID = @mssql_query($sql, $this->_connectionID);
		// Instantiate an object without considering whether 
		// the query return any results or not
		$this->_tempResultObj = new Recordset($this->_queryID);
		$this->_insertQuery($this->_queryID);
		return $this->_tempResultObj;
	}

	// Returns: the last error message from previous database
	// operation Note: This function is NOT available for
	// Microsoft SQL Server
	function errorMsg() 
	{
		$this->_errorMsg = "errorMsg() is not available for Microsoft SQL Server";
	    return $this->_errorMsg;
	}

	/*	Returns: true on success, false on failure
		Close the database connection.	*/	
	function close() {
		if ($this->_queryIDList && sizeof($this->_queryIDList > 0)) {
			while(list($_key, $_resultID) = each($this->_queryIDList)) {
				@mssql_free_result($_resultID);
			}
		}
		// If its not a persistent connection, then 
		// only the connection needs to be closed
		if ($this->_isPersistentConnection != true) {	
			return @mssql_close($this->_connectionID);
		}
		else {
			return true;
		}
	}
	
	// A PRIVATE function used by the constructor function of 
	// the query object.  insert the successful returned 
	// query id to the query id list.  Used for later results
	// cleanup.  A private function that's never meant to be 
	// used directly
	function _insertQuery($query_id) {
		$this->_queryIDList[] = $query_id;
	}		
}

//---------------------------------------
	 Class Name: Recordset
//---------------------------------------
class Recordset 
{
	/*	public variables	*/
	var $fields;
	// indicates that the current record position is 
	// before the first record in a Recordset object
	var $BOF = null;
	// indicates that the current record position is 
	// after the last record in a Recordset object
	var $EOF = null;

	// Private variables
	var $_numOfRows = -1; // NEVER change the value!  READ-ONLY!
	var $_numOfFields = -1;	// NEVER change the value!  READ-ONLY!
	
	// Holds anything that was returned from the 
	// database specific functions
	var $_tempResult = '';	
	// This variable keeps the result link identifier
	var $_queryID = -1;	
	// This variable keeps the current row in the Recordset
	var $_currentRow = -1;

	// Returns: query id on success and false if 
	// failed Constructor function
	function Recordset($queryID) 
	{
		$this->_queryID = $queryID;
		if ($queryID) {
			$this->_numOfRows = @mssql_num_rows($this->_queryID);
			$this->_numOfFields = @mssql_num_fields($this->_queryID);
		}
		else {
			$this->_numOfRows = 0;
			$this->_numOfFields = 0;
		}
		// If result set contains rows	
		if ($this->_numOfRows > 0 && $this->_currentRow == -1) {
			$this->_currentRow = 0;
			$this->fields = @mssql_fetch_array($this->_queryID);
			$this->EOF = false;
			$this->BOF = false;
		}
 		return $this->_queryID;
	}
		
	// Returns: true if successful, false if fail Set 
	// the Recordset pointer to a specified field offset. 
	// If the next call to fetchField() won't include a 
	// field offset, this field would be returned
	function fieldSeek($fieldOffset = -1) {
		$this->_tempResult = @mssql_field_seek($this->_queryID, $fieldOffset);
		return $this->_tempResult;
	}

	// Returns: an object containing field information. 
	// Get column information in the Recordset object. 
	// fetchField() can be used in order to obtain information
	// about fields in a certain query result. If the field 
	// offset isn't specified, the next field that wasn't yet 
	// retrieved by fetchField() is retrieved
	function fetchField($fieldOffset = -1) {
		if ($fieldOffset != -1) {
			$this->_tempResult = @mssql_fetch_field($this->_queryID, $fieldOffset);
		}
		// The $fieldOffset argument is not provided thus its -1
		else if ($fieldOffset == -1) {	
			$this->_tempResult = @mssql_fetch_field($this->_queryID);
		}
		return $this->_tempResult;
	}

	// Returns: true if there still rows available, or false 
	// if there are no more rows.  Moves to the next row in a 
	// specified Recordset object and makes that record the current 
	// row and the data corresponding to the row will be retrieved
	// into the fields collection.  Note: Unlike the moveRow() method, 
	// when _currentRow is getNumOfRows() - 1, EOF will immediately be 
	// true.  If row number is not provided, the function will point 
	// to the first row automatically
	function nextRow() 
	{
		if ($this->getNumOfRows() > 0) {			
			$this->fields = array();
			$this->_currentRow++;
			$this->fields = @mssql_fetch_array($this->_queryID);
			// This is not working.  True all the time
			if ($this->fields) {	
				$this->_checkAndChangeEOF($this->_currentRow - 1);
				return true;
			}
		}
		$this->EOF = true;
		return false;
	}	
			
	// Returns: true on success, false on failure moveRow() 
	// moves the internal row pointer of the Recordset object 
	// to point to the specified row number and the data 
	// corresponding to the row will be retrieved into the fields 
	// collection.  If row number is not provided, the function will 
	// point to the first row automatically
	function moveRow($rowNumber = 0) 
	{
		if ($rowNumber == 0) {
			return $this->firstRow();
		}
		else if ($rowNumber == ($this->getNumOfRows() - 1)) {
			return $this->lastRow();
		}
		if ($this->getNumOfRows() > 0 && $rowNumber < $this->getNumOfRows()) {	
			$this->fields = null;
			$this->_currentRow = $rowNumber;
			if(@mssql_data_seek($this->_queryID, $this->_currentRow)) {
				$this->fields = @mssql_fetch_array($this->_queryID);
				/*	This is not working.  True all the time	*/
				if ($this->fields) {
					// No need to call _checkAndChangeEOF() because
					// the possibility of moving to the last row has 
					// been handled by the above code
					$this->EOF = false; 
					return true;
				}
			}
		}
		$this->EOF = true;
		return false;
	}

	// Returns: true on success, false on failure firstRow() moves
	// the internal row pointer of the Recordset object to the first 
	// row and the data corresponding to the row will be retrieved 
	// into the fields collection
	function firstRow() 
	{
		if ($this->getNumOfRows() > 0) {
			$this->fields = array();
			$this->_currentRow = 0;
			if (@mssql_data_seek($this->_queryID, $this->_currentRow)) {
				$this->fields = @mssql_fetch_array($this->_queryID);
				$this->EOF = false;
				/*	This is not working.  True all the time	*/
				if ($this->fields) {	
					return true;	
				}
			}
		}
		$this->EOF = true;
		return false;		
	}

	// Returns: true on success, false on failure lastRow() moves 
	// the internal row pointer of the Recordset object to the last
	// row and the data corresponding to the row will be retrieved 
	// into the fields collection
	function lastRow() 
	{
		if ($this->getNumOfRows() > 0) {	
			$this->fields = array();	
			$num_of_rows = $this->getNumOfRows();
			$this->_tempResult = @mssql_data_seek($this->_queryID, --$num_of_rows);
			if ($this->_tempResult) {
				/*	$num_of_rows decemented at above 	*/
				$this->_currentRow = $num_of_rows;
				$this->fields = @mssql_fetch_array($this->_queryID);
				/*	This is not working.  True all the time	*/
				if ($this->fields) {
					/*	Special case for making EOF false.	*/
					$this->EOF = false;	
					return true;
				}
			}
		}
		$this->EOF = true;
		return false;
	}

	// close() only needs to be called if you are worried about using
	// too much memory while your script is running. All associated 
	// result memory for the specified result identifier will 
	// automatically be freed
	function close() {
		$this->_tempResult = @mssql_free_result($this->_queryID);		
		return $this->_tempResult;
	}

	// Returns: the number of rows in a result set.  Get 
	// number of rows in result
	function getNumOfRows() {
		return $this->_numOfRows;
	}

	/*	Returns: the number of fields in a result set. 
	Get number of fields in result.	*/
	function getNumOfFields() {
		return $this->_numOfFields;
	}       

	/*	Check and change the status of EOF.	*/		
	function _checkAndChangeEOF($currentRow) {
		if ($currentRow >= ($this->_numOfRows - 1)) {
			$this->EOF = true;
		}		
		else {
			$this->EOF = false;		
		}
	}
}
?>
</code>
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




-->
<sect> ºÎ·Ï H Sybase SQL Server DB Wrapper ¿¹Á¦ <label id="sybase H">
<p>
Á¦ÃâÀÚ : Joe Thong
       <htmlurl url="mailto:
		   darkjoe@softhome.net
			" name="
		   darkjoe@softhome.net
		">
Site URL: <url url="http://phpdb.linuxbox.com">

<bf>¼³¸í: </bf> ¿©·¯°¡Áö µ¥ÀÌÅͺ£À̽º ¼­¹ö¿¡¼­ °á°ú Á¶ÀÛÀ» À§ÇÑ °­·ÂÇÑ 
PHP µ¥ÀÌŸº£À̽º ·¦ÆÛ.  µ¥ÀÌÅͺ£À̽ºÀÇ °á°ú°¡ phpDB¿¡ ÀÇÇØ ÀÚµ¿À¸·Î ³ª¿À°Ô µÈ´Ù.

ÀÌÈ­ÀÏÀ» ¾òÀ¸·Á¸é À¥ºê¶ó¿ìÁ®¿¡¼­ '´Ù¸¥À̸§À¸·Î ÀúÀå'À» ´©¸£°í 
phpDB-sybase.lib ¶ó°í ÀÔ·ÂÇϽÿÀ.
<code>
<?php
/*
Name: phpDB Sybase module
Version: 1.02bR6
Description: A PHP database wrapper for various database 
	servers with a powerful Recordset for result data 
	manipulation.  Database results are flushed 
	automatically by phpDB.  
*/

// Define this module, to prevent double class declaration
if (!defined("_PHPDB_ABSTRACT_LAYER")) {
	define("_PHPDB_ABSTRACT_LAYER", 1 );
}
else
	return;

//-------------------------------
	 Class Name: phpDB
//-------------------------------
class phpDB 
{
	/*	public variables	*/
	var $version = '1.02bR6'; // Version number of phpDB
	// This variable keeps what database type is going 
	// to be used.  Current supported database server 
	// are MySQL, MSQL, SQL Server, and Sybase
	var $databaseType = ''; 
	// Specifies which database is going to be used
	var $databaseName = ''; 
	// The hostname of the database server, port number 
	// is optional.  e.g: "db.devNation.com"
	var $hostname = '';
	var $username = '';	// to connect to the database server
	var $password = ''; // Password for the username

	// Private variables --- starts with underscore
	// An array of executed querys.  For results 
	// cleanup purposes
	var $_queryIDList	= array();	
	// The returned link identifier whenever a successful 
	// database connection is made
	var $_connectionID	= -1;	
	// A variable which was used to keep the returned last 
	// error message.  The value will then returned by 
	// the errorMsg() function
	var $_errorMsg = '';
	// This variable keeps the last created result 
	// link identifier
	var $_queryID = -1;	
	// A boolean variable to state whether its a 
	// persistent connection or normal connection
	var	$_isPersistentConnection = false;	
	// Holds the newly created result object, returned 
	// via the execute() method
	var $_tempResultObj = '';

	// A constructor function for the phpDB object.  When 
	// initializing, specify the dbType i.e: "mysql", 
	// "msql", "postgresql", "mssql", and "sybase"
	function phpDB($dbType = "sybase") 
	{
		switch ($dbType) {
			case "mysql":
			case "msql":
			case "postgresql":
			case "mssql":
			case "sybase":						
			case "informix":						
				$this->databaseType = $dbType;
				break;
			default:
				return false;
		}			
	}
	
	// Returns: A positive link identifier on success, or
	// false on error. 	Connect to the server with the 
	// provided arguments. The connection to the server will be 
	// closed when the script terminates, unless close()
	// function is called beforehand
	function connect($argHostname = "", $argUsername = "", 
		$argPassword = "", $argDatabaseName = "") 
	{
		$boolDBSelected;
		if ($argHostname != "") {
			$this->hostname = $argHostname;
		}
		if ($argUsername != "") {
			$this->username = $argUsername;
		}
		if ($argPassword != "") {
			$this->password = $argPassword;
		}
		if ($argDatabaseName != "") {
			$this->databaseName = $argDatabaseName;
		}				
		
		$this->_connectionID = @sybase_connect($this->hostname, $this->username, $this->password);
		
		if ($this->databaseName && $this->_connectionID) {
			$boolDBSelected = @sybase_select_db($this->databaseName);
			/*	If DB selection fails	*/
			if(!$boolDBSelected) {	
				/*	Close the current connection	*/
				@sybase_close($this->_connectionID);
				return false;	
			}
		}		
		return $this->_connectionID;
	}

	// Returns: A positive link identifier on success, or false 
	// on error.  Connect to the server with the provided 
	// arguments. The connection to the server will not be closed
	// when the script terminates. Instead it will be kept for later future use
	function pconnect($argHostname = "", $argUsername = "", 
		$argPassword = "", $argDatabaseName = "") 
	{
		$boolDBSelected;
		if ($argHostname != "") {
			$this->hostname = $argHostname;
		}
		if ($argUsername != "") {
			$this->username = $argUsername;
		}
		if ($argPassword != "") {
			$this->password = $argPassword;
		}
		if ($argDatabaseName != "") {
			$this->databaseName = $argDatabaseName;
		}				
		
		$this->_connectionID = @sybase_pconnect($this->hostname, $this->username, $this->password);
		if ($this->_connectionID) {
			$this->_isPersistentConnection = true;				
		}
		
		if ($this->databaseName && $this->_connectionID) {
			$boolDBSelected = @sybase_select_db($this->databaseName);
			/*	if DB selection fails	*/
			if(!$boolDBSelected) {
				/*	Persistent connection can't be closed	*/
				return false;	
			}
		}		
		return $this->_connectionID;
	}
	
	/*	Returns: true on success, false on error 
		Select the database name to be used	*/
	function selectDB($dbName) {
		$this->databaseName = $dbName;
		if ($this->_connectionID) {
			return @sybase_select_db($dbName);		
		}
		else {
			/*	No database selected	*/
			return false;
		}			
	}

	/*	Returns: the Recordset object disregard success or failure
		Send the sql statement to the database server.	*/
	function execute($sql = "") {
		$this->_queryID = @sybase_query($sql, $this->_connectionID);
		// Instantiate an object without considering whether
		// the query return any results or not
		$this->_tempResultObj = new Recordset($this->_queryID);
		$this->_insertQuery($this->_queryID);
		return $this->_tempResultObj;
	}

	/*	Returns: the last error message from previous database operation
		Note: This function is NOT available for Sybase.	*/	

	function errorMsg() {
		$this->_errorMsg = "errorMsg() is not available for Sybase";
	    return $this->_errorMsg;
	}

	/*	Returns: true on success, false on failure
		Close the database connection.	*/	
		
	function close() {
		if ($this->_queryIDList && sizeof($this->_queryIDList > 0)) {
			while(list($_key, $_resultID) = each($this->_queryIDList)) {
				@sybase_free_result($_resultID);
			}
		}
		// If its not a persistent connection, then 
		// only the connection needs to be closed
		if ($this->_isPersistentConnection != true) {	
			return @sybase_close($this->_connectionID);
		}
		else {
			return true;
		}
	}
	
	// A PRIVATE function used by the constructor function
	// of the query object.  insert the successful returned 
	// query id to the query id list.  Used for later results 
	// cleanup.  A private function that's never meant 
	// to be used directly
	function _insertQuery($query_id) {
		$this->_queryIDList[] = $query_id;
	}		
}
	
//----------------------------------
	 Class Name: Recordset
//----------------------------------
class Recordset 
{
	/*	public variables	*/
	var $fields;
	// indicates that the current record position is 
	// before the first record in a Recordset object
	var $BOF = null;	
	// indicates that the current record position 
	// is after the last record in a Recordset object
	var $EOF = null;
	
	// Private variables - starts with underscore
	var $_numOfRows = -1; // NEVER change the value! READ-ONLY!
	var $_numOfFields = -1;	// NEVER change the value! READ-ONLY!
	// Holds anything that was returned from 
	// the database specific functions
	var $_tempResult = '';	
	// This variable keeps the result link identifier
	var $_queryID = -1;	
	// This variable keeps the current row in the Recordset
	var $_currentRow = -1;	

	// Returns: query id on success and false if 
	// failed Constructor function
	function Recordset($queryID) {
		$this->_queryID = $queryID;
		if ($queryID) {
			$this->_numOfRows = @sybase_num_rows($this->_queryID);
			$this->_numOfFields = @sybase_num_fields($this->_queryID);
		}
		else {
			$this->_numOfRows = 0;
			$this->_numOfFields = 0;
		}
		/*	If result set contains rows	*/
		if ($this->_numOfRows > 0 && $this->_currentRow == -1) {
			$this->_currentRow = 0;
			$this->fields = @sybase_fetch_array($this->_queryID);
			$this->EOF = false;
			$this->BOF = false;
		}
 		return $this->_queryID;
	}
		
	// Returns: true if successful, false if fail Set 
	// the Recordset pointer to a specified field offset. 
	// If the next call to fetchField() won't include a 
	// field offset, this field would be returned
	function fieldSeek($fieldOffset = -1) {
		$this->_tempResult = @sybase_field_seek($this->_queryID, $fieldOffset);
		return $this->_tempResult;
	}

	// Returns: an object containing field information.  
	// Get column information in the Recordset object. 
	// fetchField() can be used in order to obtain information
	// about fields in a certain query result. If the field 
	// offset isn't specified, the next field that wasn't yet
	// retrieved by fetchField() is retrieved
	function fetchField($fieldOffset = -1) {
		if ($fieldOffset != -1) {
			$this->_tempResult = @sybase_fetch_field($this->_queryID, $fieldOffset);
		}
		/*	The $fieldOffset argument is not provided thus its -1 	*/
		else if ($fieldOffset == -1) {	
			$this->_tempResult = @sybase_fetch_field($this->_queryID);
		}
		return $this->_tempResult;
	}

	// Returns: true if there still rows available, or 
	// false if there are no more rows.  Moves to the next
	// row in a specified Recordset object and makes that record 
	// the current row and the data corresponding to the row will
	// be retrieved into the fields collection.  Note: Unlike 
	// the moveRow() method, when _currentRow is getNumOfRows() - 1,
	// EOF will immediately be true.  If row number is not 
	// provided, the function will point to the 
	// first row automatically
	function nextRow() {
		if ($this->getNumOfRows() > 0) {			
			$this->fields = array();
			$this->_currentRow++;
			$this->fields = @sybase_fetch_array($this->_queryID);
			/*	This is not working.  True all the time	*/
			if ($this->fields) {
				$this->_checkAndChangeEOF($this->_currentRow - 1);
				return true;
			}
		}
		$this->EOF = true;
		return false;
	}	
			
	// Returns: true on success, false on failure moveRow()
	// moves the internal row pointer of the Recordset object 
	// to point to the specified row number and the data 
	// corresponding to the row will be retrieved into the
	// fields collection.  If row number is not provided, the
	// function will point to the first row automatically
	function moveRow($rowNumber = 0) {
		if ($rowNumber == 0) {
			return $this->firstRow();
		}
		else if ($rowNumber == ($this->getNumOfRows() - 1)) {
			return $this->lastRow();
		}
		if ($this->getNumOfRows() > 0 && $rowNumber < $this->getNumOfRows()) {	
			$this->fields = null;
			$this->_currentRow = $rowNumber;
			if(@sybase_data_seek($this->_queryID, $this->_currentRow)) {
				$this->fields = @sybase_fetch_array($this->_queryID);
				/*	This is not working.  True all the time	*/
				if ($this->fields) {	
					// No need to call _checkAndChangeEOF() 
					// because the possibility of moving to the 
					// last row has been handled by the above code
					$this->EOF = false; 
					return true;
				}
			}
		}
		$this->EOF = true;
		return false;
	}

	// Returns: true on success, false on failure firstRow()
	// moves the internal row pointer of the Recordset object
	// to the first row and the data corresponding to the row 
	// will be retrieved into the fields collection
	function firstRow() {
		if ($this->getNumOfRows() > 0) {
			$this->fields = array();
			$this->_currentRow = 0;
			if (@sybase_data_seek($this->_queryID, $this->_currentRow)) {
				$this->fields = @sybase_fetch_array($this->_queryID);
				$this->EOF = false;
				/*	This is not working.  True all the time	*/
				if ($this->fields) {
					return true;	
				}
			}
		}
		$this->EOF = true;
		return false;		
	}

	// Returns: true on success, false on failure lastRow() 
	// moves the internal row pointer of the Recordset object
	// to the last row and the data corresponding to the row
	// will be retrieved into the fields collection
	function lastRow() {
		if ($this->getNumOfRows() > 0) {	
			$this->fields = array();	
			$num_of_rows = $this->getNumOfRows();
			$this->_tempResult = @sybase_data_seek($this->_queryID, --$num_of_rows);
			if ($this->_tempResult) {
				/*	$num_of_rows decemented at above 	*/
				$this->_currentRow = $num_of_rows;
				$this->fields = @sybase_fetch_array($this->_queryID);
				/*	This is not working.  True all the time	*/
				if ($this->fields) {
					/*	Special case for making EOF false.	*/
					$this->EOF = false;
					return true;
				}
			}
		}
		$this->EOF = true;
		return false;
	}

	// close() only needs to be called if you are worried
	// about using too much memory while your script is 
	// running. All associated result memory for the 
	// specified result identifier will automatically be freed
	function close() {
		$this->_tempResult = @sybase_free_result($this->_queryID);		
		return $this->_tempResult;
	}

	/*	Returns: the number of rows in a result set. 
	Get number of rows in result.	*/
	
	function getNumOfRows() {
		return $this->_numOfRows;
	}

	/*	Returns: the number of fields in a result set. 
	Get number of fields in result.	*/
		
	function getNumOfFields() {
		return $this->_numOfFields;
	}       

	/*	Check and change the status of EOF.	*/		
	function _checkAndChangeEOF($currentRow) {
		if ($currentRow >= ($this->_numOfRows - 1)) {
			$this->EOF = true;
		}		
		else {
			$this->EOF = false;		
		}
	}
}
?>
</code>
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




-->
<sect> ºÎ·Ï I phpDB.inc ¿¹Á¦ <label id="phpdb I">
<p>
Á¦ÃâÀÚ : Joe Thong
       <htmlurl url="mailto:
		   darkjoe@softhome.net
			" name="
		   darkjoe@softhome.net
		">
Site URL: <url url="http://phpdb.linuxbox.com">

<bf>Description: </bf> ¿©·¯°¡Áö µ¥ÀÌÅͺ£À̽º ¼­¹ö¿¡¼­ °á°ú Á¶ÀÛÀ» À§ÇÑ °­·ÂÇÑ 
PHP µ¥ÀÌŸº£À̽º ·¦ÆÛ.  µ¥ÀÌÅͺ£À̽ºÀÇ °á°ú°¡ phpDB¿¡ ÀÇÇØ ÀÚµ¿À¸·Î ³ª¿À°Ô µÈ´Ù.

ÀÌÈ­ÀÏÀ» ¾òÀ¸·Á¸é À¥ºê¶ó¿ìÁ®¿¡¼­ '´Ù¸¥À̸§À¸·Î ÀúÀå'À» ´©¸£°í 
phpDB.inc ¶ó°í ÀÔ·ÂÇϽÿÀ.
<code>
<?php
/*
Name: phpDB General module
Version: 1.02bR6
Description: A PHP database wrapper for various 
	database servers.  Database results are flushed 
	automatically by phpDB.  Supported database 
	servers are MySQL, MSQL, PostgreSQL, Microsoft 
	SQL Server and Sybase. 
*/

	if (!defined("_PHPDB_GENERAL_LAYER")) {
	  define("_PHPDB_GENERAL_LAYER", 1 );
	}
	else
		return;
	
	// Fill in the database server that you're
	// going to use.  Consult the phpDB Reference
	// Manual for more information
	$databaseType = '';
	// The phpDB module root path.  No trailing slash
	$phpDBRootPath = '.';	
	
	function useDB($dbType = "") 
	{
		GLOBAL $phpDBRootPath;
		switch (strtolower($dbType)) 
		{
			case "mysql":
			case "msql":
			case "postgresql":
			case "mssql":
			case "sybase":
			case "informix":
				include("$phpDBRootPath". "/phpDB-" . "$dbType.lib");
				break;
			case "":
				die("Please edit phpDB.inc in order to use phpDB");
				return false;
			default:
				die("Invalid database selection");
				return false;		
		}					
		return true;		
	}
	
	useDB($databaseType);
?>
</code>
<!--
	*******************************************
	************ End of Section ***************
	*******************************************




-->
<sect> ºÎ·Ï J phpDBTest.php3 ¿¹Á¦ <label id="phpDBTest">
<p>
Á¦ÃâÀÚ : Joe Thong
       <htmlurl url="mailto:
		   darkjoe@softhome.net
			" name="
		   darkjoe@softhome.net
		">
Site URL: <url url="http://phpdb.linuxbox.com">

<bf>¼³¸í: </bf> ¿©·¯°¡Áö µ¥ÀÌÅͺ£À̽º ¼­¹ö¿¡¼­ °á°ú Á¶ÀÛÀ» À§ÇÑ °­·ÂÇÑ 
PHP µ¥ÀÌŸº£À̽º ·¦ÆÛ.  µ¥ÀÌÅͺ£À̽ºÀÇ °á°ú°¡ phpDB¿¡ ÀÇÇØ ÀÚµ¿À¸·Î ³ª¿À°Ô µÈ´Ù.

ÀÌÈ­ÀÏÀ» ¾òÀ¸·Á¸é À¥ºê¶ó¿ìÁ®¿¡¼­ '´Ù¸¥À̸§À¸·Î ÀúÀå'À» ´©¸£°í 
phpDB-mssql.lib ¶ó°í ÀÔ·ÂÇϽÿÀ.(¿ªÁÖ: phpDB-mssql.lib °¡ ¾Æ´Ï°í. phpDBTest.php3 ¶ó°íÇØ¾ßÇÕ´Ï´Ù.)
<code>
<html>
< head>
	< title>Untitled< /title>
< /head>

< body>
<?php
	// ÀÌÈ­ÀÏÀº phpDB.inc°¡ ÀÖ´Â µð·ºÅ丮¿¡ ÀÖ´Ù°í °¡Á¤ÇÕ´Ï´Ù.
	include("phpDB.inc");	
	$db = new phpDB();
	$db->pconnect("hostName", "userName", "passWord", "databaseName") or die ("Can't connect to database server or select database");
	$rs = $db->execute("SELECT * FROM Items");
	$numOfRows = $rs->getNumOfRows();
	echo "Number of Rows: $numOfRows";	

	$rs->firstRow(); // ¼±ÅûçÇ×À̳ª, ÃßõÇÕ´Ï´Ù.
	while (!$rs->EOF) {
		// Fields collection accessible as associative arrays too
		echo "<br>" . $rs->fields[0];
		$rs->nextRow();	// NOTE: nextRow() is placed at below
	}

	$rs->close();		
	$db->close();	// ¼±ÅûçÇ×
?>
< /body>
< /html>
</code>
<!-- 
*******************************************
************ End of Section ***************
*******************************************




-->
</article>





sponsored by andamiro
sponsored by cdnetworks
sponsored by HP

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-04-17 15:49:35
Processing time 0.0091 sec