2010”N02ŒŽ03“ú

PHP+MySQL‚Ńgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“

‚Ƃ��‚¤‚�}‚Ƃō¡‰ñ‚ÍPHP+MySQL‚Ńgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚Å‚·B

ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚Æ‚Í‹à—Z‚̃VƒXƒeƒ€‚É•K—v•s‰ÂŒ‡‚ȏˆ—‚Å‚·B

ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚Á‚ĉ½H‚Á‚Ä•û‚͂�}‚�}‚ð‚²——‚É‚È‚Á‚Ä
‚»‚̏d—v«‚ð’m‚Á‚��‚½‚¾‚«‚½‚��

‚ł̓\[ƒX‚Å‚·B
<?

	if ( !extension_loaded( "mysql" ) ) {
		dl( "php_mysql.dll" );
	}

	//Ú‘�}—p•ï¿½ï¿½Žš—ñ
	$Server = "ƒT[ƒo–¼";
	$DbName = "ƒf[ƒ^ƒx[ƒX–¼";
	$User = "ƒ†[ƒU–¼";
	$Password = "ƒpƒXƒ[ƒh";

	//Ú‘�}
	$Connect = @mysql_connect( $Server, $User, $Password );
	if( !$Connect ){
		print "Ú‘�}‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½";
		exit();
	}

	//DB‚Ì‘I‘ð
	mysql_select_db( $DbName, $Connect );

	//ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚ð‚͂��‚߂鏀”õ
	$Query = "set autocommit = 0";
	mysql_query( $Query, $Connect );

	//ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“ŠJŽn
	$Query = "begin";
	mysql_query( $Query, $Connect );

	//insertŽÀs
	$Query = "insert into ŽÐˆõƒ}ƒXƒ^ values( '0001', 'redwarcueid')";

	$result = mysql_query( $Query, $Conncet );

	if( $result === true ){

		//ƒRƒ~ƒbƒg
		$Query = "commit";
		mysql_query( $Query, $Connect );
		print "ƒRƒ~ƒbƒg‚µ‚Ü‚µ‚½";

	}else{

		//ƒ[ƒ‹ƒoƒbƒN
		$Query = "rollback";
		mysql_query( $Query, $Connect );
		print "ƒ[ƒ‹ƒoƒbƒN‚µ‚Ü‚µ‚½";

	}

	//MySQLØ’f
	mysql_close( $Connect );

?>

‚�}‚̃\[ƒX‚Å‚Íinsert‚ðŽÀs‚µAï¿½ï¿½Œï¿½ï¿½‚µ‚½ê‡‚̓Rƒ~ƒbƒgA Ž¸”s‚µ‚½ê‡‚̓[ƒ‹ƒoƒbƒN ‚Ƃ��‚¤ˆ—‚ð‚µ‚Ä‚ï¿½ï¿½‚Ü‚·B ‚¿‚È‚Ý‚Émysql_queryŠÖ”‚Íinsert•ï¿½ï¿½‚È‚Ç‚ÌŒ‹‰Ê‚ð•Ô‚³‚Ȃ��•ï¿½ï¿½‚ɑ΂·‚é–ß‚è’l‚Í true‚©false‚É‚È‚è‚Ü‚·B ÅŒã‚Ƀgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚ð‚͂��‚߂鏀”õ‚Ƃ��‚¤‚Ƃ�}‚ë‚Íautocommit‚ª1‚̏ꍇ‚Í ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“’†‚Å‚àŠÖŒW‚È‚­ƒNƒGƒŠ‚ªï¿½ï¿½Œï¿½ï¿½‚·‚é‚Æ‚»‚̏ê‚Å ƒRƒ~ƒbƒg‚µ‚Ä‚µ‚Ü‚¤‚Ì‚Å0‚É‚µ‚ăgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚ðŽn‚ß‚Ü‚µ‚傤 ’ˆÓ‚µ‚Ü‚µ‚傤 I‚í‚è
posted by redwarcueid at 00:15| ‘åã ☁| Comment(0) | PHP | ‚}‚̃uƒƒO‚Ì“ÇŽÒ‚É‚È‚é | XVî•ñ‚ðƒ`ƒFƒbƒN‚·‚é
‚�}‚Ì‹LŽ–‚ւ̃Rƒƒ“ƒg
ƒRƒƒ“ƒg‚ð‘‚­
‚�N–¼‘O:

ƒ[ƒ‹ƒAƒhƒŒƒX:

ƒz[ƒ€ƒy[ƒWƒAƒhƒŒƒX:

ƒRƒƒ“ƒg:

”FØƒR[ƒh: [•K{“ü—Í]


¦‰æ‘œ‚Ì’†‚̕��Žš‚𔼊p‚Å“ü—Í‚µ‚Ä‚­‚¾‚³‚��B