ȸ¿ø°¡ÀԡžÆÀ̵ð/ºñ¹øã±â
ȨÀ¸·Î


Flex 2 ¿Í PHP+MYSQL ¿¬µ¿ ¿¹Á¦
12³â Àü
Flex2 ¿Í PHP ¿ÍÀÇ ¿¬µ¿ ¿¹Á¦¸¦ Adobe ¿¡¼­ Á÷Á¢ Ä£ÀýÇÏ°Ô Á¦½ÃÇØ ÁÖ¾ú´Ù.
Á¦½ÃÇØÁص¥·Î °£´ÜÇÑ È¸¿ø Ãß°¡/Á¶È¸ ±â´ÉÀÇ ¿¹Á¦¸¦ ¸¸µé¾î º¸¾Ò´Ù.

¿¹Á¦¿¡ ¾²ÀÎ Áغñ¹° : php, mysql, flex2 sdk


1. ȸ¿ø Á¤º¸¸¦ ´ã¾ÆµÑ °£´ÜÇÑ db table Àº ¸¸µç´Ù.


CREATE TABLE users(
userid INT NOT NULL auto_increment,
username VARCHAR( 255 ) NOT NULL ,
emailaddress VARCHAR( 255 ) NOT NULL
)



2. ȸ¿ø Á¤º¸¸¦ Ãß°¡ÇÏ´Â DB INSERT , Á¶È¸ÇÒ¶§ XML µ¥ÀÌÅÍ·Î ¶³±¸´Â ±â´ÉÀÇ °£´ÜÇÑ php ÆÄÀÏÀ» ¸¸µç´Ù.

[request.php]

<?php
define( "DATABASE_SERVER", "localhost" );
define( "DATABASE_USERNAME", "root" );
define( "DATABASE_PASSWORD", "" );
define( "DATABASE_NAME", "sample" );

//connect to the database
$mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD);

mysql_select_db( DATABASE_NAME );

// Quote variable to make safe
function quote_smart($value)
{
   // Stripslashes
   if (get_magic_quotes_gpc()) {
       $value = stripslashes($value);
   }
   // Quote if not integer
   if (!is_numeric($value)) {
       $value = "'" . mysql_real_escape_string($value) . "'";
   }
   return $value;
}

if( $_POST["emailaddress"] AND $_POST["username"])
{
      //add the user
      $Query = sprintf("INSERT INTO users VALUES ('', %s, %s)", quote_smart($_POST['username']), quote_smart($_POST['emailaddress']));

      $Result = mysql_query( $Query );
}

//return a list of all the users
$Query = "SELECT * from users";
$Result = mysql_query( $Query );

$Return = "<users>";

while ( $User = mysql_fetch_object( $Result ) )
{
      $Return .= "<user><userid>".$User->userid."</userid><username>".$User->username."</username><emailaddress>".$User->emailaddress."</emailaddress></user>";
}
$Return .= "</users>";
mysql_free_result( $Result );
print ($Return)
?>


Äڵ带 º¸¸é ´Ù ¾Ë°ÚÁö¸¸ °£´ÜÈ÷ ¼³¸íÀ» µ¡ºÙÀÌÀÚ¸é,
$_POST °ªÀÌ ³Ñ¾î¿À¸é db INSERT °¡ ÀϾ°í,
users Å×À̺íÀÇ µ¥ÀÌÅ͸¦ °¡Á®¿Í xml µ¥ÀÌÅÍ Çü½ÄÀ¸·Î ¸¸µé¾î¼­ »Ñ·ÁÁØ´Ù.


3. flex ¿ÍÀÇ ¿¬µ¿À» À§ÇÑ »çÀü ÁغñÀÛ¾÷Àº ¿©±â±îÁö. ÀÌÁ¦ º»°ÝÀûÀÎ flex ÄÚµùÀÌ´Ù.
¿©±â¼­´Â ÆíÀÇ»ó ȸ¿ø Ãß°¡Æû°ú ȸ¿ø ¸®½ºÆ®°¡ ÇÑÆäÀÌÁö¿¡ ±¸¼ºµÇ¾îÀÖ´Ù.

[user.mxml]

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" creationComplete="userRequest.send()">
   <mx:HTTPService id="userRequest" url="http://yourDomain.com/yourPath/request.php" useProxy="false" method="POST">
      <mx:request xmlns="">
         <username>{username.text}</username><emailaddress>{emailaddress.text}</emailaddress>
      </mx:request>
   </mx:HTTPService>
   <mx:Form x="22" y="10" width="493">
      <mx:HBox>
         <mx:Label text="Username"/>
         <mx:TextInput id="username"/>
      </mx:HBox>
      <mx:HBox>
         <mx:Label text="Email Address"/>
         <mx:TextInput id="emailaddress"/>
      </mx:HBox>
      <mx:Button label="Submit" click="userRequest.send()"/>
   </mx:Form>
   <mx:DataGrid id="dgUserRequest" x="22" y="128" dataProvider="{userRequest.lastResult.users.user}">
      <mx:columns>
         <mx:DataGridColumn headerText="User ID" dataField="userid"/>
         <mx:DataGridColumn headerText="User Name" dataField="username"/>
      </mx:columns>
   </mx:DataGrid>
   <mx:TextInput x="22" y="292" id="selectedemailaddress" text="{dgUserRequest.selectedItem.emailaddress}"/>
</mx:Application>


swf °¡ ·ÎµùÀÌ ³¡³ª¸é(Application ÀÇ creationComplete="userRequest.send()") HTTPService ·Î request.php ¸¦ È£ÃâÇÏ¿© request.php °¡ ¸¸µé¾îÁØ xml ÆÄÀÏÀÇ µ¥ÀÌÅ͸¦ ¹ÙÀεù ÇÑ´Ù.

ȸ¿øÀ» Ãß°¡ÇÏ°í Submit ¹öÆ°À» Ŭ¸¯Çϸé request.php ·Î username,emailaddress °ªÀ» post ¹æ½ÄÀ¸·Î ³Ñ±ä´Ù.

flex °¡ Á¦°øÇÏ´Â ¸·°­ÇÑ ¸®½ºÆ® (ÇÏÁö¸¸ ¹«°Å¿î ¤¾¤¾) DataGrid ·Î ¹ÙÀεùÇÑ µ¥ÀÌÅ͵éÀ» ¿À¸§Â÷¼ø(lastResult)À¸·Î »Ñ·ÁÁØ´Ù.

4. user.mxml À» ÄÄÆÄÀÏ ÇÑ ÈÄ, »ý¼ºµÈ user.swf ¸¦  request.php °¡ Àִ°÷À¸·Î ¾÷·Îµå ÇÑ´Ù.
°æÇè»ó, user.swf ¿Í request.php ÆÄÀÏÀÌ °°Àº ¼­¹ö¿¡ ÀÖÁö ¾ÊÀ¸¸é http·Î ½ÃÀÛÇÏ´Â Àý´ëÁÖ¼Ò·Î µµ¸ÞÀÎÀ¸·Î ¸ÂÃçÁشٰí ÇÏ´õ¶óµµ Åë½ÅÀÌ Á¦´ë·Î ÀÌ·ç¾îÁöÁö ¾Ê´Â´Ù. ÀÌÀ¯´Â Àß ¸ð¸£°Ú´Ù;;

ÀÌÁ¦ ¼­¹ö¿¡ ¿Ã·ÁÁø user.swf ¸¦ ºê¶ó¿ìÀú¿¡¼­ ¿­¾îº¸ÀÚ.


HTTPService ¸¦ ÀÌ¿ëÇؼ­ ¸Å¿ì °£´ÜÇÏ°Ô flex ¿Í php »çÀÌÀÇ xml µ¥ÀÌÅÍ Åë½ÅÀÌ ÀÌ·ç¾îÁ³´Ù.
Ưº°È÷ php + mysql ¿¡ ƯȭµÈ ¹æ¹ýÀ̶ó°í´Â º¼ ¼ø ¾ø°í, ¶³±¸´Â xml Çü½Ä¸¸ ¸ÂÃçÁشٸé jsp,asp µîÀÇ ´Ù¸¥ ½ºÅ©¸³Æ® ¾ð¾îµµ °¡´ÉÇÏ´Ù.
¹°·Ð db ¿ª½Ã ²À mysql ¾Æ´Ï¿©µµ ¼­¹öÃø ½ºÅ©¸³Æ®¿Í ¿¬µ¿ °¡´ÉÇÑ ¸ðµç db »Ó¸¸ ¾Æ´Ï¶ó, ¶³±¸´Â µ¥ÀÌÅ͸¦ xml Çü½ÄÀ¸·Î ¸ÂÃçÁֱ⸸ ÇÑ´Ù¸é ÆÄÀÏ ÇüÅÂÀÇ µ¥ÀÌÅ͵µ °¡´ÉÇÒ °ÍÀ¸·Î º¸ÀδÙ.

flex 2 ÀÇ db ¿ÍÀÇ ¿¬µ¿Àº ÀÌÁ¤µµ¿¡ ±âÃÊÇؼ­ ÀÀ¿ëÇØ ³ª°¡´Â°Ô ÁÁÀ»¹ý ½Í´Ù.
ÃßõÃßõ : 585 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
245
CSS Intro
244
CSS¿ë¾î Á¤¸®
243
±¹³»IP Á¤º¸ Á¶È¸Çϴ Ŭ·¡½º(php)
242
php->xml »ý¼ºÇÏ´Â class
241
socketÀÌ¿ëÇÑ Å¸»çÀÌÆ® À̹ÌÁö Àбâ
240
»çÀÌÁî°¡ Å«À̹ÌÁö À¥ÆäÀÌÁö Ãâ·Â½Ã ÀÚµ¿À¸·Î »çÀÌÁî ÁÙÀ̱â...
239
ƯÁ¤ÇÑ ´ÞÀÇ »ýÀÏÀÎ »ç¶÷ ¸®½ºÆ® °¡Á®¿À±â
238
PHP¿Í AjaxÀ» ÀÌ¿ëÇؼ­ µ¥ÀÌÅÍ Ã³¸®Çϱâ
237
ÆÄÀÏÀ» ¹«Á¶°Ç ´Ù¿î·Îµå ½ÃÅ°±â
236
include()¿ë À¥°æ·Î -> »ó´ë°æ·Î º¯È¯ ÇÔ¼ö
235
ºü¸¥ ÇÁ·Î¼¼¼­¸¦ À§ÇÑ ÄÚµù½ºÅ¸ÀÏ
234
¿¢¼¿(*.xls) È­ÀÏÀ» PHP¿¡¼­ Àбâ
233
ÆÄÀÏ ´Ù¿î·Îµå ÇÔ¼ö(¸ÖƼ À̾î¹Þ±â/¼ÓµµÁ¦ÇÑ)
232
Áֹεî·Ï ¹øÈ£·Î ³ªÀÌ ±¸Çϱâ
231
cURLÀ» ÀÌ¿ëÇÑ À¥ÆäÀÌÁö °¡Á®¿À±â
230
ÃÖ´ë°ø¾à¼ö ±¸Çϱâ (À¯Å¬¸®µå ¾Ë°í¸®Áò)
229
¼Ò¼öÀÎÁö È®ÀÎÇϱâ (À¯Å¬¸®µå ¾Ë°í¸®Áò)
228
¹®ÀÚ¿­À» X·Î ¸¶Å·ÇÏ´Â ÇÔ¼ö
227
ÆÄÀÏ ´Ù¿î·Îµå2 (Çì´õ ÀÌ¿ë)
226
ÀԷ¹ÞÀº IPÁÖ¼Ò¸¦ 127.0.¡Ù.1 ÇüÅ·Π¹Ù²Þ.
225
DBÀÇ ¹«ÇÑÄ«Å×°í¸® °¡Á®¿À±â
224
¾î¶² °æ·Î·Î Çؼ­ ÀÌ È¨¿¡ ¿À°Ô µÆ´ÂÁö ¾Ë¾Æ³»´Â ¹æ¹ý
223
Ç×»ó »õ·Î°íħ ÇØ´õ ¼³Á¤
222
Ç×»ó Çѱ۷Π³ª¿Àµµ·Ï ÇØ´õ¼³Á¤
221
PHP·Î ÀÛµ¿ÇÏ´Â RSS Àд ÇÔ¼ö
220
Ç÷¡½Ã ÆÄÀÏ Á¤º¸ ¾ò¾î¿À´Â ¼Ò½º(PHP)
219
¹®ÀÚ¿­À» X·Î ¸¶Å·ÇÏ´Â ÇÔ¼ö
218
¸ÖƼ ÆÄÀÏ ¾÷·Îµå ¿¹Á¦ (Flex2+PHP)
Flex 2 ¿Í PHP+MYSQL ¿¬µ¿ ¿¹Á¦
216
DB ³»¿ë ¿¢¼¿·Î »Ì¾Æ¿À±â ( ÆÄ¿öÆ÷ÀÎÆ®, MS ¿öµå°¡´É )
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.