1. Çü½Ä
Çü½Ä1) myres_ptr= mysql_list_dbs(mysql)
Çü½Ä2) myres_ptr= mysql_list_dbs(mysql, wild)
2. ±â´É: Á¢¼ÓµÈ MySQL ¼¹öÀÇ µ¥ÀÌÅͺ£À̽º ¸ñ·ÏÀ» ¾ò´Â´Ù.
3. ¼³¸í
(1) ÀÌ ÇÔ¼ö´Â MySQL¿¡¼ Áö¿øÇÏ´Â ÇÔ¼öÀ̸ç ÇÔ¼ö¸íÀº MySQLÀÇ C API¿Í µ¿ÀÏÇÏ´Ù.
(2) ÀÎÀÚ mysqlÀº MySQL Æ÷ÀÎÅÍÀ̸ç MySQL ¿¬°á½Ã ¾òÀº °ªÀÌ°í MySQL Æ÷ÀÎÅÍ°¡
¾Æ´Ï¸é ¿¡·¯ 󸮵Ǹç, ÀÌ¹Ì Æó¼âµÈ MySQL Æ÷ÀÎÅÍÀÏ ¶§¿¡´Â °æ°í ¸Þ½ÃÁö¸¦
Ãâ·ÂÇÏ°í result¿¡ -1 ÀÇ °ªÀ» µÇµ¹¸°´Ù.
(3) MySQLÀÇ µ¥ÀÌÅͺ£À̽º ¸ñ·ÏÀ» ¾òÁö ¸øÇϸé Á¤¼ö -1(MYSQL_ERR)ÀÌ myres_ptr¿¡
µ¹·ÁÁø´Ù.
(4) ¼³¸í(2)¿Í ¼³¸í(3)ÀÇ °æ¿ì°¡ ¾Æ´Ï¸é Àӽà ÀúÀåµÈ ÀÚ·á¿¡ ´ëÇÑ MySQL result
Æ÷ÀÎÅÍ°¡ myres_ptr¿¡ µ¹·ÁÁø´Ù.
(5) Çü½Ä2)ÀÇ ÀÎÀÚ wild´Â wildcard¸¦ ÁöÁ¤ÇÏ´Â °ÍÀ¸·Î ÇØ´ç Á¶°Ç¿¡ ¸Â´Â ¸íĪÀÇ
¸ñ·Ï¸¸ ¾òÀ¸¸ç ¹®ÀÚ¿ÀÌ ¾Æ´Ï¸é ¹®ÀÚ¿·Î Çüº¯È¯ÇÑ´Ù.
(6) ÀÎÀÚ wildÀÇ »ç¿ë¿¹
1) abc% --> abc¶ó´Â ¸íĪÀ¸·Î ½ÃÀ۵Ǵ °Í¸¸ ´ë»óÀ¸·Î ÇÑ´Ù.
2) %abc --> abc¶ó´Â ¸íĪÀ¸·Î ³¡³ª´Â °Í¸¸ ´ë»óÀ¸·Î ÇÑ´Ù.
3) %abc% --> abc¶ó´Â ¸íĪÀ» Æ÷ÇÔÇÏ°í ÀÖ´Â °Í¸¸ ´ë»óÀ¸·Î ÇÑ´Ù.
4. »ç¿ë¿¹#1
// ¾Æ·¡ÀÇ ¿¹Á¦´Â ¿¬°áµÈ MySQL¿¡ ÃÖ¼Ò 3°³ÀÇ µ¥ÀÌÅͺ£À̽º°¡ Á¸ÀçÇÑ´Ù°í °¡Á¤ÇÔ
mysql= mysql_connect(NULL, myuser, mypass); // localhost¸¦ ¿¬°áÇÑ´Ù.
if(mysql==MYSQL_ERR) { print("MySQL ¼¹ö ¿¬°á ¿¡·¯!\n"); return(-1); }
myres= mysql_list_dbs(mysql); // ¾ò¾îÁø ¸ñ·ÏÀÇ Ç׸ñ¸íÀº Database ÀÌ´Ù.
if(myres==MYSQL_ERR) { print("error!\n"); return; }
mysql_fetch_global(myres); // Database º¯¼ö¿¡ °ªÀÌ ¾ò¾îÁü
mysql_fetch_global(myres, "dbase#"); // dbase1 º¯¼ö¿¡ °ªÀÌ ¾ò¾îÁü
mysql_fetch_global(myres, "ms_"); // ms_Database º¯¼ö¿¡ °ªÀÌ ¾ò¾îÁü
mysql_free_result(myres);
mysql_close(mysql);
printf("DB ¸í= [%s] [%s] [%s]\n", Database, dbase1, ms_Database);
------------------------------ [ Ãâ·Â°á°ú ] ------------------------------
DB ¸í= [test] [test2] [welhelp]
5. »ç¿ë¿¹#2
// ¾Æ·¡ÀÇ ¿¹Á¦´Â ¿¬°áµÈ MySQL¿¡ ÃÖ¼Ò 3°³ÀÇ µ¥ÀÌÅͺ£À̽º°¡ Á¸ÀçÇÑ´Ù°í °¡Á¤ÇÔ
mysql= mysql_connect(NULL, myuser, mypass); // localhost¸¦ ¿¬°áÇÑ´Ù.
if(mysql==MYSQL_ERR) { print("MySQL ¼¹ö ¿¬°á ¿¡·¯!\n"); return(-1); }
myres= mysql_list_dbs(mysql, "wel%"); // wel ·Î ½ÃÀ۵Ǵ ¸íĪ¸¸ ¾ò´Â´Ù.
if(myres==MYSQL_ERR) { print("error!\n"); return; }
mysql_fetch_global(myres); // Database º¯¼ö¿¡ °ªÀÌ ¾ò¾îÁü
mysql_fetch_global(myres, "dbase#"); // dbase1 º¯¼ö¿¡ °ªÀÌ ¾ò¾îÁü
mysql_fetch_global(myres, "ms_"); // ms_Database º¯¼ö¿¡ °ªÀÌ ¾ò¾îÁü
mysql_free_result(myres);
mysql_close(mysql);
printf("DB ¸í= [%s] [%s] [%s]\n", Database, dbase1, ms_Database);
------------------------------ [ Ãâ·Â°á°ú ] ------------------------------
DB ¸í= [welhelp] [weltest] [welboard2]
|