½ÃÀÛÆäÀÌÁö·Î Áñ°Üã±âÃß°¡
·Î±×ÀÎ
ȸ¿ø°¡ÀÔ l Ã⼮üũ l ¸¶ÀÌÆäÀÌÁö l CGIMALL
ÀÚ·á½Ç »çÀÌÆ®µî·Ï ·©Å·100 ÇÁ·Î±×·¥¸®ºä °ü¸®ÀÚÃßõÀÚ·á Ãʺ¸°¡À̵å
Ä¿¹Â´ÏƼ
Àüü ÆîÃ帱â
Äü¸Þ´º¸µÅ© jquery , CSS , PHP , Javascript , ¹«·áÆùÆ® , ASP
»ó¼¼°Ë»ö
Ȩ > Ä¿¹Â´ÏƼ > °ñµåÆÁ »ó¼¼º¸±â
Ä¿¹Â´ÏƼ ±¸Àα¸Á÷
»çÀÌÆ®µî·Ï
Ŭ¶ó¿ìµåű×
javascript
PHP
ASP
CSS
mysql
html
jquery
������
image
mobile
API
slide
°Ô½ÃÆÇ
ÇöÀçÁ¢¼ÓÀÚ ¸í »õ·Î°íħ
°Ô½ÃÆÇŸÀÌƲ °ñµåÆÁ / »ó¼¼º¸±â
Æ®À§ÅÍ·Î º¸³»±â
Ãßõ¼ö 469 | Á¶È¸¼ö 7,468 | µî·ÏÀÏ 2000-11-21 00:00:27

´Ð³×ÀÓ

HappyCGI

Á¦¸ñ

1. Perl DBI ¼³Ä¡Çϱâ
³»¿ë
ÇØÇÇCGI À¥¸¶½ºÅÍ À±¿µ¿õÀÔ´Ï´Ù.

¿ì¼± perl ¿Í mysqlÀÇ ¿¬µ¿ÀÇ °³³äÀûÀÎ °Í ºÎÅÍ ¼³¸íÀ» ÇÏ°Ú½À´Ï´Ù.
http://www.happycgi.com/index.cgi?action=main&category=µ¥ÀÌŸº£À̽º_â°í/MySQL/MYSQL_ÀÚ·á/APIs/PERL_DBI

À§ URL·Î °¡º¸¸é 4°³ÀÇ ÆÄÀÏÀÌ ¿Ã¶ó¿Í ÀÖ½À´Ï´Ù.
ÀÌ´Â DBI¶õ °ÍÀ¸·Î perlÀÌ ÁØ sql ¸í·É¾îÀ» sql·Î º¸³»ÁÖ´Â ¿ªÈ°À» ÇÕ´Ï´Ù.
´ç¿¬È÷ DBI °¡ ±ò·ÁÀÖÁö ¾ÊÀ¸¸é perl°ú sqlÀº ¼­·Î ¿¬µ¿ÀÌ µÉ¼ö ¾ø°ÚÁÒ?
(¸ðµç ¾ð¾î´Â °ÅÀÇ °°Àº ÇüŸ¦ ÃëÇÕ´Ï´Ù. ¹æ¹ý»óÀ¸·Î ¾à°£¾¿ ´Ù¸£ÁÒ)

DBI ¼³Ä¡´Â ¼­¹öÀÇ root°¡ ÇØ¾ß Çϸç ÀÚ½ÅÀÌ ¼­¹ö¸¦ ¿î¿µÇÏ°í ÀÖÁö ¾ÊÀ»
°æ¿ì¿¡´Â ´ã´ç¼­¹ö°ü¸®ÀÚ´Ô²² ¿¬¶ôÀ» Çؼ­ ÆÞ DBI ¼³Ä¡¸¦ ÇØ´Þ¶ó°í
¿äûÀ» ÇÏ¼Å¾ß ÇÕ´Ï´Ù.
¸¸¾à ¼­¹ö°ü¸®ÀÚ´Ô²²¼­ "±×°Ô ¹¹¿¹¿ä?"  ÇϽŴٸé
È£½ºÆà ȸ»ç¸¦ ¹Ù²Ù½Ã´Â°Ô ³´°Ú½À´Ï´Ù. ^^;;;

¿ì¼± ³×°³ÀÇ ÆÄÀÏÀ» ´Ù¿î ¹Þ½À´Ï´Ù.
http://search.cpan.org ¿¡¼­ ¹ÞÀ¸½Ã¸é µÇ°í, ÃֽŹöÁ¯À» ¹ÞÀ¸½Ê½Ã¿À.
¼­¹öÀÇ /tmp µð·ºÅ丮¿¡ 4°³ÀÇ ÆÄÀÏÀ» ¿Ã¸³´Ï´Ù.
ÅÚ³ÝÀ¸·Î Á¢¼ÓÇÑÈÄ ·çÆ®·Î Àç·Î±äÇÕ´Ï´Ù.
¼³Ä¡ ¼ø¼­´Â

[Àοë±Û]
1. Data-ShowTable-3.3.tar.gz
2. Data-Dumper-2.101.tar.gz
3. DBI-1.13.tar.gz
4. Msql-Mysql-modules-1.2209.tar.gz


·Î ÇÏ¸é µË´Ï´Ù.

°¢°¢ÀÇ ¼³Ä¡ ¹ýÀº µ¿ÀÏÇϹǷΠÇѹø¸¸ ¼³Ä¡¹ýÀ» ¾Ë·Áµå¸®°Ú½À´Ï´Ù.
³ª¸ÓÁö´Â °°Àº ¹æ¹ýÀ¸·Î ÇÏ½Ã¸é µË´Ï´Ù.


[Àοë±Û]
1.Data-ShowTable-3.3.tar.gz ÀÇ ¾ÐÃàÀ» DZ´Ï´Ù.
ÅÚ³Ý> tar xvfz Data-ShowTable-3.3.tar.gz

2. ¾ÐÃàÀÌ Ç®¸®¸é¼­ µð·ºÅ丮°¡ »õ·Î »ý±é´Ï´Ù.
3. »ý¼ºµÈ µð·ºÅ丮·Î µé¾î°©´Ï´Ù.
4. perl Makefile.PL À̶ó°í ÀÔ·Â
5. make ¶ó°í ÀÔ·Â
6. make test ¶ó°í ÀÔ·Â
7. make install ¶ó°í ÀÔ·Â


°°Àº ¹æ¹ýÀ¸·Î ³ª¸ÓÁö 3°³ÀÇ ¸ðµâµµ ¼³Ä¡¸¦ ÇÕ´Ï´Ù.

DBI °¡ ¼³Ä¡µÇ¾ú´ÂÁö »ùÇà cgi·Î Å×½ºÆ®¸¦ Çغ¼±î¿ä?
¾Æ·¡´Â test.cgi ÀÔ´Ï´Ù.
º¹»çÇϼż­ Å×½ºÆ®Çغ¸¼¼¿ä.

¿ì¼± mysql ¿¡ ¾ÆÀ̵𸦠test Æнº¸¦ test·Î °¡Á¤À» ÇÏ°í
sql DB À̸§À» testdb
±×¸®°í Å×ÀÌºí ¸íÀº first
Ä÷³Àº name varchar(20), email varchar(20) À¸·Î °¡Á¤ÇÕ´Ï´Ù.
°ªµéÀº

À±¿µ¿õ|webmaster@happycgi.com
¼Õ´Ô |guest@test.com

À̶õ µÎ°³ÀÇ °ªÀÌ ÀÖ´Ù°í °¡Á¤À» Çϱ¸¿ä.

Âü°í·Î sql ¹®¹ýÀ» ¸ð¸£¸é ¿¬µ¿À» ºÒ°¡´ÉÇÏ°ÚÁÒ. ^^

¾Æ·¡´Â »ùÇà cgiÀÔ´Ï´Ù. º¸¸é¼­ ¼³¸íÀ» ÇÏÁÒ.


[ÇÁ·Î±×·¥ÄÚµå]
#!/usr/bin/perl
#########################################################
use DBI; #DBI¶õ ¸ðµâÀ» »ç¿ëÇÑ´Ù°í ¼±¾ðÇÕ´Ï´Ù.
$database = "testdb";
$hostname = "localhost";
$dsn = "DBI:mysql:database=$database;host=$hostname";
$user = "test";
$pw = "test";
$dbh = DBI->connect("$dsn", "$user", "$pw");
#########################################################
print "content-type:text/html\n\n";

#DB Ä¿³ØÆÃÀ» ½ÃµµÇÕ´Ï´Ù.
#À̸§ÀÌ °ø¹éÀÌ ¾Æ´Ñ°ÍµéÀ» ºÒ·¯³À´Ï´Ù.

$sth = $dbh->prepare("select * from first where name is not null or die print "$DBI::errsrt";
$sth->execute();
#@rows = $sth->fetchrow_array ¶õ $sth ¿¡¼­ ¹ÞÀº °ªµéÀ»
#¹è¿­·Î ¹Þ¾Æ º¸°Ú´Ù´Â ¸»ÀÔ´Ï´Ù.
#ÇöÀç Ä÷³ÀÌ µÎ°³´Ï±î ¹è¿­ 0¹ø°ú 1¹øÀ» °¢°¢
#$name À̶õ º¯¼ö¿Í $email À̶õ º¯¼ö·Î ÁöÁ¤À» ÇÏ°í
#Ãâ·ÂÀ» ÇÕ´Ï´Ù.

while (@rows = $sth->fetchrow_array) {
$name = $rows[0];
$email = $rows[1];
print "À̸§ : $name À̸ÞÀÏ : $email
\n";
}


À̸§°ú À̸ÞÀÏÀÌ Á¤»óÀûÀ¸·Î Ãâ·ÂÀÌ µÇ¸é DBI°¡ Àß ¼³Ä¡ µÈ°ÍÀÔ´Ï´Ù.
¸¸¾à ¾î¶² ¿À·ù ¸Þ¼¼Áö¸¦ º¸Àδٸé DBI¿¡¼­ Ãâ·ÂµÇ´Â ¿¡·¯ ¸Þ¼¼Áö
ÀÔ´Ï´Ù.
¸Þ¼¼Áö¸¦ Àß º¸½Ã°í ¾î¶»°Ô ¿¡·¯°¡ ³µ´ÂÁö ÆľÇÀ» ÇÑÈÄ ´Ù½Ã
½ÇÇàÀ» ÇÏ¼Å¾ß ÇÕ´Ï´Ù.
À̹ø ù¹ø° °­Á´ ÀÌ·¸°Ô ¸¶Ä¨´Ï´Ù.

ÁÁÀº ÇÏ·çµÇ¼¼¿ä.
³¯¾¾ ¿äÁò ¹«Áö Ã䱺¿ä. ^^

Copyright 1997-2003 HAPPYCGI All Rights Reserved.
Ãßõ½ºÅ©·¦¼Ò½ºº¸±â ¸ñ·Ï
HappyCGI 2003-01-07 00:15:50
´ä±Û

1¹ø °ú 2¹øÀº ¼ø¼­¸¦ ¹Ù²Ù¼Åµµ µË´Ï´Ù

ÀÌÀü°Ô½Ã±Û ÆÞ °­Á Áøµµ °èȹǥ 2000-11-20 23:48:22
´ÙÀ½°Ô½Ã±Û 1-1. perl DBI ,DBD(¿À¶óŬ) ¼ÂÆÃÇϱâ 2000-11-27 05:37:30