MySqlÎÞÏÞ·ÖÀàÊý¾Ý½á¹¹
ÎÞÏÞ·ÖÀàÊÇÎÒÃÇ¿ª·¢Öзdz£³£¼ûµÄÓ¦Óã¬ÏñÂÛ̳µÄµÄ°æ¿é£¬CMSµÄÀà±ð£¬Ó¦Óõĵط½Ìرð¶à¡£
ÎÒÃÇ×î³£¼û×î¼òµ¥µÄ·½·¨¾ÍÊÇÔÚMySqlÀïID ,parentID,name£º
ÓŵãÊǼòµ¥£¬½á¹¹¼òµ¥¡£
ȱµãÊÇЧÂʲ»¸ß£¬ÒòΪÿһ´ÎµÝ¹é¶¼Òª²éѯÊý¾Ý¿â£¬¼¸°ÙÌõÊý¾Ý¿âʱ¾Í²»ÊǺܿìÁË£¡
´æ´¢Ê÷ÊÇÒ»ÖÖ³£¼ûµÄÎÊÌ⣬¶àÖÖ½â¾ö·½°¸¡£Ö÷ÒªÓÐÁ½ÖÖ·½·¨£ºÁÚ½Ó±íµÄÄ£ÐÍ£¬²¢ÐÞ¸ÄÊ÷Ç°Ðò±éÀúËã·¨¡£
ÎÒÃǽ«Ì½ÌÖÕâÁ½ÖÖ·½·¨µÄ½ÚÄܵȼ¶µÄÊý¾Ý¡£ÎÒ»áʹÓÃÊ÷´ÓÒ»¸öÐé¹¹µÄÍøÉÏʳƷÉ̵ê×÷Ϊһ¸öÀý×Ó¡£ÕâʳƷÉ̵ê×éÖ¯ÆäʳƷÀ࣬ͨ¹ýÑÕÉ«ºÍÀàÐÍ¡£Õâ¿ÃÊ÷¿´ÆðÀ´ÏñÕâÑù£º
ÏÂÃæÎÒÃǽ«ÓÃÁíÍâÒ»ÖÖ·½·¨£¬Õâ¾ÍÊÇÔ¤ÅÅÐò±éÀúÊ÷Ëã·¨(modified preorder tree traversal algorithm)
ÕâÖÖ·½·¨´ó¼Ò¿ÉÄܽӴ¥µÄ±È½ÏÉÙ£¬³õ´ÎʹÓÃÒ²²»ÏñÉÏÃæµÄ·½·¨ÈÝÒ×Àí½â£¬µ«ÊÇÓÉÓÚÕâÖÖ·½·¨²»Ê¹Óõݹé²éѯËã·¨£¬Óиü¸ßµÄ²éѯЧÂÊ¡£
ÎÒÃÇÊ×ÏȽ«¶à¼¶Êý¾Ý°´ÕÕÏÂÃæµÄ·½Ê½»ÔÚÖ½ÉÏ£¬ÔÚ¸ù½ÚµãFoodµÄ×ó²àдÉÏ 1 È»ºóÑØ×ÅÕâ¸öÊ÷¼ÌÐøÏòÏ ÔÚ Fruit µÄ×ó²àдÉÏ 2 È»ºó¼ÌÐøÇ°½ø£¬ÑØ×ÅÕû¸öÊ÷µÄ±ßÔµ¸øÿһ¸ö½Úµã¶¼±êÉÏ×ó²àºÍÓÒ²àµÄÊý×Ö¡£×îºóÒ»¸öÊý×ÖÊDZêÔÚFood ÓÒ²àµÄ 18¡£ ÔÚÏÂÃæµÄÕâÕÅͼÖÐÄã¿ÉÒÔ¿´µ½Õû¸ö±êºÃÁËÊý×ֵĶ༶½á¹¹¡££¨Ã»Óп´¶®£¿ÓÃÄãµÄÊÖÖ¸Ö¸×ÅÊý×Ö´Ó1Êýµ½18¾ÍÃ÷°×Ôõô»ØÊÂÁË¡£»¹²»Ã÷°×£¬ÔÙÊýÒ»±é£¬×¢ÒâÒƶ¯ÄãµÄÊÖÖ¸£©¡£
ÕâЩÊý×Ö±êÃ÷Á˸÷¸ö½ÚµãÖ®¼äµÄ¹Øϵ£¬"Red"µÄºÅÊÇ3ºÍ6£¬ËüÊÇ "Food" 1-18 µÄ×ÓËï½Úµã¡£ ͬÑù£¬ÎÒÃÇ¿ÉÒÔ¿´µ½ ËùÓÐ×óÖµ´óÓÚ2ºÍÓÒֵСÓÚ11µÄ½Úµã ¶¼ÊÇ"Fruit" 2-11 µÄ×ÓËï½Úµã
ÈçͼËùʾ£º
ÕâÑùÕû¸öÊ÷×´½á¹¹¿ÉÒÔͨ¹ý×óÓÒÖµÀ´´æ´¢µ½Êý¾Ý¿âÖС£¼ÌÐø֮ǰ£¬ÎÒÃÇ¿´Ò»¿´ÏÂÃæÕûÀí¹ýµÄÊý¾Ý±í¡£
×¢Ò⣺ÓÉÓÚ"left"ºÍ"right"ÔÚ SQLÖÐÓÐÌØÊâµÄÒâÒ壬ËùÒÔÎÒÃÇÐèÒªÓÃ"lft"ºÍ"rgt"À´±íʾ×óÓÒ×ֶΡ£ ÁíÍâÕâÖֽṹÖв»ÔÙÐèÒª"parent"×Ö¶ÎÀ´±íʾÊ÷×´½á¹¹¡£Ò²¾ÍÊÇ ËµÏÂÃæÕâÑùµÄ±í½á¹¹¾Í×ã¹»ÁË¡£
SELECT * from tree WHERE lft BETWEEN 2 AND 11;
¿´µ½ÁË°É£¬Ö»ÒªÒ»¸ö²éѯ¾Í¿ÉÒԵõ½ËùÓÐÕâЩ½Úµã¡£ÎªÁËÄܹ»ÏñÉÏÃæµÄµÝ¹éº¯ÊýÄÇÑùÏÔʾÕû¸öÊ÷×´½á¹¹£¬ÎÒÃÇ»¹ÐèÒª¶ÔÕâÑùµÄ²éѯ½øÐÐÅÅÐò¡£ÓýڵãµÄ×óÖµ½øÐÐÅÅÐò£º
SELECT * from tree WHERE lft BETWEEN 2 AND 11 ORDER BY lft ASC;
ÄÇôij¸ö½Úµãµ½µ×ÓжàÉÙ×ÓËï½ÚµãÄØ£¿ºÜ¼òµ¥£¬×ÓËï×ÜÊý=(ÓÒÖµ-×óÖµ-1)/2&nb
Ïà¹ØÎĵµ£º
ÏÈÇ°ÔÚ²âÊÔmysql connect c++½Ó¿ÚµÄʱºòÔËÐÐÆä¹Ù·½ÌṩµÄÀý×Ó
21.5.5.6. MySQL Connector/C++ Complete Example 2
The following code shows a complete example of how to use MySQL Connector/C++:
/* Copyright 2008 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify ......
¶¨ÆÚά»¤ÄãµÄÊý¾Ý±í¡£
¹¤¾ß£ºmysqlcheck myisamchk
mysqlcheck¿Í»§¶Ë¿ÉÒÔ¼ì²éºÍÐÞ¸´MyISAM±í¡£Ëü»¹¿ÉÒÔÓÅ»¯ºÍ·ÖÎö±í¡£
mysqlcheckµÄ¹¦ÄÜÀàËÆmyisamchk£¬µ«Æ乤×÷²»Í¬¡£
Ö÷Òª²î±ðÊǵ±mysqld·þÎñÆ÷ÔÚÔËÐÐʱ±ØÐëʹÓÃmysqlcheck£¬¶ømyisamch ......
ʹÓÃwhileÑ»·Óï¾äÉú³É²âÊÔÊý¾Ý£º
ÏÂÃæµÄ·½·¨ÊÇͨ¹ý´´½¨Ò»¸ö´æ´¢¹ý³Ì£¬È»ºóÔÙµ÷ÓÃÕâ¸ö´æ´¢¹ý³ÌÀ´ÊµÏֵģ¬´ÓÍøÉÏÕÒÁ˺ܶ෽·¨£¬µ«¶¼Ã»Óгɹ¦¡£
delimiter // /*¶¨ÒåÃüÁî½áÊø·ûĬÈÏΪ ; */
create procedure genUsers()
begin
declare i int default 0;
while i < 40 do
insert into users(userID,userName, ......
Linux + Apache2.0 + Mysql + PHP + phpBB3.0
1.°²°ü£º
Apache2.0
#tar -zxf httpd-***.tar.gz -C /usr/local/src/
#cd /usr/local/src/httpd-***
  ......
MySQL³£ÓõĴ洢ÒýÇæΪMyISAM¡¢InnoDB¡¢MEMORY¡¢MERGE£¬ÆäÖÐInnoDBÌṩÊÂÎñ°²È«±í£¬ÆäËû´æ´¢ÒýÇ涼ÊÇ·ÇÊÂÎñ°²È«±í¡£
MyISAMÊÇMySQLµÄĬÈÏ´æ´¢ÒýÇæ¡£MyISAM²»Ö§³ÖÊÂÎñ¡¢Ò²²»Ö§³ÖÍâ¼ü£¬µ«Æä·ÃÎÊËٶȿ죬¶ÔÊÂÎñÍêÕûÐÔûÓÐÒªÇó¡£
InnoDB´æ´¢ÒýÇæÌṩÁ˾ßÓÐÌá½»¡¢»Ø¹öºÍ±ÀÀ£»Ö¸´ÄÜÁ¦µÄÊÂÎñ°²È«¡£µ«ÊDZÈÆðMyISAM´æ´ ......