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


flex + 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 ¿ÍÀÇ ¿¬µ¿Àº ÀÌÁ¤µµ¿¡ ±âÃÊÇؼ­ ÀÀ¿ëÇØ ³ª°¡´Â°Ô ÁÁÀ»¹ý ½Í´Ù.
ÃßõÃßõ : 549 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
193
³×Æ®¿öÅ© ¿ë¾îµé
192
¿©·¯ Å×À̺íÀÇ ÃÖ±Ù °Ô½Ã¹° ÃßÃâ (union all »ç¿ë)
191
°°Àº ·¹ÄÚµåÁß¿¡ ÃÖ°í°ª ±¸Çϱâ
190
¿Ã¹Ù¸¥ ¼øÀ§ Á¤·Ä °á°ú¸¦ ¾ò´Â ¹æ¹ý
189
[MySQL] Áߺ¹µÈ ÇʵåÀÇ °¹¼ö ±¸Çϱâ
188
À¯´ÏÄÚµå ÀÎÄÚµùÇϱâ
187
jquery cookie
186
´Ù¸¥ ¼­¹ö·Î °ªÀ» Àü¼ÛÈÄ °á°ú°ªÀ» ¹Þ´Â ¹æ¹ý
185
DB¿¡¼­ DATA ¸¦ ºÒ·¯¿À´Â ¹æ¹ý
184
find ¸í·ÉÀ¸·Î ÃÖ±Ù º¯°æµÈ ÆÄÀÏ °Ë»ö / ÆÄÀÏ ³»¿ë °Ë»ö
183
¾ÆÀÌÆù, ¾Èµå·ÎÀÌµå ¹ÙÅÁÈ­¸é¿¡ ¹Ù·Î°¡±â ¸¸µé±â
182
À¥È£½ºÆà ÀÌ¿ëÀÚ°¡ ¾÷·Îµå ¿ë·® ´Ã¸®±â
181
PHP·Î HTTP ÀÎÁõÇϱâ
180
phpinfo Á¤º¸ - ¹Ì¸® Á¤ÀÇµÈ º¯¼ö
179
¼¼¼ÇÀ» ÀÌ¿ëÇÑ µ¿½Ã ·Î±×ÀÎ ¹æÁö
178
µð·ºÅ丮³»ÀÇ ¸ðµç ÆÄÀÏ ¹× Æú´õ »èÁ¦ ÇÔ¼ö (Recursive call)
177
Flex¿Í MySQLÀÇ ¿¬µ¿ (PHP»ç¿ë)
flex + php + mysql
175
»çÀÌÆ® ȯ°æ¼³Á¤ÀÇ ¹æ¹ý
174
$_SERVER[DOCUMENT_ROOT]ÀÇ Ç¥Çö¹æ¹ý
173
$PHP_SELF °¡ ¾ÈµÉ¶§
172
PHP·Î ±¸ÇöÇÑ °Ô½ÃÆÇ ÀÚµ¿ µî·Ï±â Ŭ·¡½º
171
MD5¸¦ ÀÌ¿ëÇÑ ¾Ïȣȭ/º¹È£È­
170
linux command ¸®´ª½º È°¿ë ¸í·Éµé..
169
º¸¾ÈÀ» À§ÇÑ php ÇÔ¼ö Á¦ÇÑ
168
mysql¿¡¼­ ÇѱÛÀÌ ±úÁú¶§ Áï ¹®ÀÚ¼ÂÀÌ ¸ÂÁö ¾ÊÀ»¶§
167
Mysql ³¯Â¥/½Ã°£ °ü·Ã ÇÔ¼ö
166
PHP È®ÀåÀÚ ¼û±â±â
165
PHP ¿¡·¯ Ãâ·Â ¾ÈÇϱâ
164
phpinfo() ¸¦ ¼û°Ü¶ó...
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.