dbix :: tree :: nestedset."Áßø µÈ ¼¼Æ®"»óÀ§ / ÀÚ½Ä Æ®¸®¸¦ ±¸ÇöÇÕ´Ï´Ù. | |
Áö±Ý ´Ù¿î·Îµå |
dbix :: tree :: nestedset. ¼øÀ§ ¹× ¿ä¾à
±¤°í
- ƯÇã:
- Perl Artistic License
- °¡°Ý:
- FREE
- °Ô½ÃÀÚ À̸§:
- Dan Collis Puro
- °Ô½ÃÀÚ À¥»çÀÌÆ®:
- http://search.cpan.org/~djcp/
dbix :: tree :: nestedset. ű×
dbix :: tree :: nestedset. ¼³¸í
"Áßø µÈ ¼¼Æ®"ºÎ¸ð / ÀÚ½Ä Æ®¸®¸¦ ±¸ÇöÇÕ´Ï´Ù. dbix :: tree :: nestedsetÀº "Áßø µÈ ¼¼Æ®"»óÀ§ / ÇÏÀ§ Æ®¸®¸¦ ±¸ÇöÇÏ´Â Perl ¸ðµâÀÔ´Ï´Ù. #! / usr / bin / perl #ÀÌ / usr / bin / perl # ÀÌ°ÍÀº dbix :: treeÀÇ "scripts / tree_example.pl"ÀÔ´Ï´Ù. : Áßø ¼¼Æ® ¹èÆ÷´Â ¾ö°ÝÇÕ´Ï´Ù. °æ°í¸¦ »ç¿ëÇϽʽÿÀ. dbix :: tree :: nestedsetÀ» »ç¿ëÇϽʽÿÀ. DBI¸¦ »ç¿ëÇϽʽÿÀ. #create ¿¬°á. ¿ì¸®´Â Áö±Ý SQLite¸¦ »ç¿ëÇÒ °ÍÀÔ´Ï´Ù. #my $ dbh = dbi-> connect ( 'dbi : mysql : test', '»ç¿ëÀÚ', 'Æнº') ¶Ç´Â ´ÙÀÌ ($ dbi :: errstr); MY $ dbh = dbi-> connect ( 'dbi : sqlite2 : test') ¶Ç´Â ´ÙÀÌ ($ dbi :: errstr); ³» $ db_type = 'sqlite'; #my $ db_type = 'mysql'; ³» $ tree = dbix :: tree :: nestedset-> new (dbh => $ dbh, db_type => $ db_type); #ÀÌ µå¶óÀ̹ö Àμ⿡ ´ëÇØ Å×À̺íÀ» »ý¼ºÇÏ´Â ¹æ¹ýÀ» »ìÆì º¸°Ú½À´Ï´Ù. "$ DB_TYPE¿¡ ´ëÇÑ Å×ÀÌºí ¹® »ý¼º : "; $ tree-> get_default_create_table_statement ()¸¦ ÀμâÇϽʽÿÀ." "# $ tree-> create_default_table (); #create ·çÆ® ³ëµå. ³» $ root_id = $ tree-> add_child_to_right (name => 'food'); #second ·¹º§ My $ Vegetable_ID = $ tree-> add_child_to_right (id => $ root_id, name => ''¾ßä '); my $ animal_id = $ tree-> add_child_to_right (id => $ root_id, name =>'a manimal '); my $ mineral_id = $ tree-> add_child_to_right ( id => $ root_id, name => 'mineral'); #thrure "foreach ( 'froot', 'beans', 'legumes', 'tree-> legumes') {$ tree-> add_child_to_right (id =>) $ vegetable_id, name => $ _} #TRIMER "À§Á¶ ( '¼è°í±â', '´ß°í±â', 'Çػ깰') {$ tree-> add_child_to_right (id => $ Animal_ID, À̸§ => $ _ #hey! ¿ì¸®´Â µÅÁö °í±â¸¦ ÀØ¾î ¹ö·È½À´Ï´Ù! ´Ù¸¥ ¹éÀÎ °í±â´Â ÀØ¾î ¹ö·È½À´Ï´Ù! # ±×°ÍÀº "µ¿¹°"±ºÁß Áß¿¡¼ óÀ½À̾î¾ßÇÕ´Ï´Ù. $ tree-> add_child_to_left (id => $ Animal_ID, À̸§ => 'µÅÁö "); $ tree-> edit_node (id => $ trea-> get_id_by_key (key_name => 'name', key_value => 'froot'), À̸§ => '°úÀÏ'); # ÀÚ½Ä ³ëµåÀÇ ÀÚ½Ä ³ëµå 2 Â÷ ¼öÁØ "µ¿¹°"³ëµå My $ Children = $ TREA-> get_self_and_children_flat (id => $ lim al_id); # "µ¿¹°"ÀÌ°íÀÌ ÇÏÀ§ Æ®¸®ÀÇ #parent ÀΠù ¹ø° ³ëµå¸¦ ±×·¡. MY $ PARENT = SHIFT @ $ ¾î¸°ÀÌ; '»óÀ§ ³ëµå :'. $ »óÀ§ ³ëµå -> {name} "¸¦ ÀμâÇϽʽÿÀ." "¾ÆÀ̵éÀ» ÅëÇØ #loopÀ» ÅëÇØ ¹º°¡¸¦Çضó. ³» $ ¾î¸°ÀÌ (@ $ ¾î¸°ÀÌ) {$ ¾î¸°À̸¦ ÀμâÇϽʽÿÀ. '. $ ¾î¸°ÀÌ -> {id}'. '. $ ¾î¸°ÀÌ -> {name} " ";} #mineral? ±×°ÍÀ» Á¦°ÅÇϽʽÿÀ. $ tree-> delete_self_and_children (id => $ mineral_id); # ¸ðµâ¿¡ ³»Àå µÈ Ãʺ¸ÀûÀÎ º¸°í¼¸¦ # ÀμâÇϽʽÿÀ." ¿ÏÀüÇÑ ³ª¹« : "Àμâ $ tree-> create_report ();ÀÌ ¸ðµâÀº"Áßø µÈ ¼¼Æ® "ºÎ¸ð / ÀÚ½Ä Æ®¸®¸¦ ±¸ÇöÇÏ°í À¥ ÀÀ¿ë ÇÁ·Î±×·¥À»º¸´Ù ½±°Ô °³¹ßÇÏ´Â ¹æ¹ýÀ» Á¦°øÇÏ´Â ¹æ¹ýÀ» Á¦°øÇÕ´Ï´Ù. ÀϹÝÀûÀ¸·Î À¯¿ëÇؾßÇÕ´Ï´Ù. SETED SET Æ®¸®ÀÇ ÀåÁ¡°ú ±â´ÉÀ» ¼³¸íÇÏ´Â ¸®¼Ò½º¿¡ ´ëÇÑ "Âü°í »çÇ×"¼½¼Ç.ÀÌ ¸ðµâÀº DBI¸¦ ÅëÇÑ °£´ÜÇÑ ¸Þ¼Òµå Àμö ¹× ÀúÀå¼Ò¸¦ ÅëÇØ ³ëµå¿Í ¿¬°üµÈ ¸ÞŸ µ¥ÀÌÅ͸¦ ÀÓÀÇÀÇ ³ëµå ¼öÁØÀ¸·Î Á¦°øÇÕ´Ï´Ù. ÇöÀç MySQL ¹× SQLite ¹öÀüÀ» À§ÇØ ±¸Çö µÈ µå¶óÀ̹ö°¡ ÀÖ½À´Ï´Ù. ¸î °¡Áö ÀÌÀ¯·ÎÀÌ ¸ðµâÀº SQLite¸¦ ½ÇÇàÇÏ´Â µ¥ ÇÊ¿äÇÑ ³» ¸ðµâÀ» SegFaults·Î ¼³Á¤ÇÕ´Ï´Ù. SQLite 3À» ¾Ë¾Æ³¾ ¼ö ¾øÀ¸¸é SQLite 2¸¦ »ç¿ëÇϽʽÿÀ. dbix :: tree :: nestedset :: mySQL ¿¹Á¦ µå¶óÀ̹ö¿¡ ´ëÇÑ mysqlÀ» ÂüÁ¶ÇϽʽÿÀ. »ðÀÔ, »èÁ¦ ¶Ç´Â ³ëµåÀÇ À̵¿¿¡¼ Æ®¸®¸¦ ²Ï ºñÆ®·Î ÆíÁýÇؾßÇϱ⠶§¹®¿¡ Áßø µÈ ¼³Á¤ Æ®¸®ÀÔ´Ï´Ù. ¹Ý´ë·Î , ³ª¹«ÀÇ Äõ¸®¿¡ ´ëÇÑ "Àú·Å"ÀÔ´Ï´Ù. E ÇϳªÀÇ SQL ¹®À¸·Î °ÅÀÇ ¸ðµç ÇൿÀ» °ÅÀÇ ¸ðµç Á¶Ä¡ (Àڳฦ ¾ò°í, ÀڸŸ¦ °¡Á® ¿À±â, ÇüÁ¦ ÀڸŠµî)À» ¼öÇà ÇÒ ¼ö ÀÖ½À´Ï´Ù. ¸¹Àº ÀбⰡ ÇÊ¿äÇÑ ¾ÛÀ» °³¹ßÇÏ°í Æ®¸®¿¡ ´ëÇÑ ¾÷µ¥ÀÌÆ®°¡ °ÅÀÇ ¾ø½À´Ï´Ù (¿¹ : ¸ðµç À¥ ¾Û ÀÌÁ¦±îÁö °Ç¼³ µÈ) Áßø µÈ ¼¼Æ®´Â ÀϹÝÀûÀÎ ÀÎÁ¢ ¸í´Ü ¸ñ·Ï ¸ðµ¨¿¡ ÀÇÇØ ¿ä±¸µÇ´Â Àç±Í Äõ¸®¿¡ ºñÇØ »ó´çÇÑ ¼º´É ÀÌÁ¡À» Á¦°øÇؾßÇÕ´Ï´Ù. »¡¸® 3 ¹ø. create_default_table () ¸Þ¼µå¸¦ »ç¿ëÇÏ¿© RDBMS¿¡ Áßø µÈ ¼¼Æ® Å×À̺íÀ» ¸¸µì´Ï´Ù. ¿ä±¸ »çÇ× : ¡¤ Perl.
dbix :: tree :: nestedset. °ü·Ã ¼ÒÇÁÆ®¿þ¾î