MYSQL °üº¬ÊÂÎï,²ÎÊý,ÓαêµÈµÄ×ÛºÏʹÓÃÀý×Ó,Ç°ÕÂ(1)
----------------------------------------------------------------------
--¸Ã´æ´¢¹ý³ÌÓû§´¦ÀíÐÅÏ¢,µ±Êý¾Ý²»´æÔÚ±íÖÐʱÔò²åÈç,·ñÔò¾Íɾ³ý
--Ö»ÓÃÁ˼òµ¥µÄÊÂÎñ,ÏÂÃ潫Óиü¸´ÔÓµÄÀý×Ó
--pro_produce ²úÆ·±í(pname.p_id(±àºÅ,Ö÷¼ü),ptime(Ìí¼Óʱ¼ä))
--
--
--
-------------------------------------------------------------------------
create procedure pro_produce(
in pname varchar(50),
in pb int,
in ptime datetime,
out rtn int)
begin
declare al_d int default -1;
[--Èç¹û³öÏÖÒì,»ò×Ô¶¯´¦Àí²¢ÇÒrollback,µ«²»ÔÙ֪ͨµ÷Ó÷½(×¢Òâ:µ«Èç¹ûÏ£Íûµ÷Ó÷½µÃµ½ÏûÏ¢,ÐèÒªÕâÒ»¾ä:declare exit handler for sqlexception rollback;ÒÔ¼°Æô¶¯ÊÂÎñºÍÌá½»ÊÂÎñµÄÓï¾äÈ«²¿È¥µô)]
select p_id into al_d from t_produce where p_name=pname;
if al_d=-1 then
--¿ªÆôÊÂÎñ
start transcation;
nsert into t_produce value(pname,pb,ptime);
--Ìí¼ÓÈÕ¼Ç
insert into t_log where (datetime,'Ìí¼ÓÁËвúÆ·');
--Ìá½»ÊÂÎñ
set rtn=1;
commit;
else
set rtn=0;
end if;
end
Ïà¹ØÎĵµ£º
mysql(°üÀ¨ËùÓÐ5.*ϵÁÐ,5.1.21֮ǰ)µÄÂý²éѯÈÕ־ĬÈÏÊÇÒÔÃëΪµ¥Î»µÄ,¿ÉÒÔͨ¹ýset [session|global] long_query_time=1Õâ¸ö×îµÍÒ²¾ÍÊÇ¿ÉÒÔÉèÖõ½1Ãë,¶ÔÓÚ0.5,0.005Ö®Àà¾ÍÎÞÄÜΪÁ¦ÁË,Õâʱºò¿ÉÒÔÓÐmicroslow patch(msl patch)²¹¶¡À´Íê³ÉÕâÒ»¹¤×÷,Õâ¸ö¹¦Äܵĺô¦×ÔÈ»²»ÑÔ¶øÓ÷. ÔÚmysql5.1.21¼°ÒÔºó°æ±¾¿ÉÒÔͨ¹ýset [session|gl ......
³£³£Óöµ½´óÊý¾ÝÁ¿Æµ·±¶ÁдÊƱػᵼÖ·þÎñÆ÷µÄÐÔÄÜϽµ¡£ÏÂÃæ¼Ç¼һ϶ÔmysqlµÄÓÅ»¯ÅäÖÃ
1.Ê×ÏȹرÕauto commit¡£
2.¶ÔÓÚÊý¾Ý±íʹÓÃInnoDB¡£
3.¹Ø±ÕÍâ¼üÔ¼Êø¡£
4.²ÉÓöàÖµ²åÈë“INSERT INTO ±íÃû VALUES (1,2), (5,5), ...;” Èç¹ûÓдóÁ¿²¢·¢¿ÉÒÔÓøü¸ÄINSERT INTOΪ INSERT DELAYED INTO¿ÉÒÔÔڳ̶ÈÉϽ⾠......
<?php
/*
* by:lenush
* qicq:707207845
* email:lenus-h@163.com
* site:www.hackthiswebsite.cn
* that's all
*
*/
class mysql{
private $db_host; //Êý¾Ý¿âÖ÷»ú
private $db_user; //Êý¾Ý¿âÓû§Ãû
private $d ......
1.Ê×ÏȵöÔmysql ÀïÃæµÄ²ÎÊý½øÐнéÉÜÏÂ:
procedure--in:ÊäÈë²ÎÊý,outÊä³ö²ÎÊý,inoutÕâ¸ö¾Í²»ÓÃ˵ÁË,´ó¸ÅÒ²²Âµ½ÁË
declare:ÉùÃ÷±äÁ¿.¼ÇÖ÷, ......