Professional Web Applications Themes

Generic MySQL/PHP Tree Schema? - MySQL

Folks, any url's around re subject matter? Performance isn't necessarily a problem, and the depth will be under, say, twenty. Thanks, all. --AS...

  1. #1

    Default Generic MySQL/PHP Tree Schema?

    Folks, any url's around re subject matter? Performance isn't
    necessarily a problem, and the depth will be under, say, twenty.

    Thanks, all.

    --AS

    ashore Guest

  2. #2

    Default Re: Generic MySQL/PHP Tree Schema?

    On May 14, 12:52 pm, ashore <com> wrote: 

    <http://www.google.com/search?q=sql+tree+structure>

    ZeldorBlat Guest

  3. #3

    Default Re: Generic MySQL/PHP Tree Schema?

    ZeldorBlat wrote: 
    >
    > <http://www.google.com/search?q=sql+tree+structure>
    >[/ref]

    If you're looking to create a menu type tree you need to look into
    recursion, i use a function like below, not saying this is the best as
    I'm a newbie but it work and creates a menu tree, I then use another
    function to p this tree into the format i need (usually html) using
    another similar recursing function.

    public function makeTree( $menu_seq, $depth ) {

    $sql = "SELECT * FROM menu WHERE menu_parent=" . $menu_seq . "
    ORDER BY menu_dspseq ASC;";
    $ds = mysql_query( $sql ) or die(mysql_error());
    if (mysql_num_rows($ds)>0) {
    while ( $dr = mysql_fetch_assoc($ds) ) {
    $sql = "SELECT COUNT(menu_seq) FROM menu WHERE
    menu_parent = " . $dr['menu_seq'];
    $dsc = mysql_query($sql);
    $drc = mysql_fetch_array($dsc);
    $array[$dr['menu_seq']]['menu_text'] =
    htmlentities($dr['menu_text']);
    $array[$dr['menu_seq']]['menu_parent'] =
    $dr['menu_parent'];
    $array[$dr['menu_seq']]['menu_page'] =
    $dr['menu_page'];
    $array[$dr['menu_seq']]['depth'] = $depth;
    if ($drc>0) {
    $array[$dr['menu_seq']]['children'] =
    $this->makeTree( $dr['menu_seq'], $depth+5 );
    } else {
    $array[$dr['menu_seq']]['children'] = null;
    }
    }
    mysql_free_result($ds);
    }
    return (isset($array) ? $array : false);

    }
    Tyno Guest

  4. #4

    Default Re: Generic MySQL/PHP Tree Schema?

    Thanks, all - yr responses are appreciated.

    Now, answering my own posting in case others are following this
    thread: Do take a look at

    http://freshmeat.net/projects/nodetree/

    Pretty good, actually.

    -AS

    ashore Guest

  5. #5

    Default Re: Generic MySQL/PHP Tree Schema?

     


    I think if you're going to have any kind of volume and depth at all,
    it's probably better to stay away from recursive solutions, since you
    could end up with an awful lot of queries per page load. Of course,
    you could use caching or something to minimize this, but... I like
    outline style solutions, where you keep all your data in one table and
    have one column that keeps some data outline style ("1.12.5" or
    similar) It looks like that nodetree project uses soemthing like
    this...

    Aerik

    Aerik Guest

  6. #6

    Default Re: Generic MySQL/PHP Tree Schema?

    The application area I have in mind here is a crisis management/
    tracking/dispatch operation, in which there's a hierarchy of component
    steps comprising the collection of responses. (Ex: a storm, in which
    roads, bridges, waterways, telecommunications facilities, hospitals,
    etc., are affected, with distinct problems associated with each.)

    Kind of like a work breakdown structure, but somewhat more dynamic. I
    looked at some project management applications, but a cursory scan
    showed nothing like what we're discussing here -- although I can't
    imagine we're breaking new ground.

    -AS

    ashore Guest

  7. #7

    Default Re: Generic MySQL/PHP Tree Schema?

    ashore wrote: 

    It's ancient technology, but look at MUMPS, the Massachusetts
    General Hospital system from the 1970s.

    John Nagle
    John Guest

  8. #8

    Default Re: Generic MySQL/PHP Tree Schema?

    On 14 Mai, 18:52, ashore <com> wrote: 

    Look at this: "Managing Hierarchical Data in MySQL" (
    http://dev.mysql.com/tech-resources/articles/hierarchical-data.html )

    maruerru Guest

  9. #9

    Default Re: Generic MySQL/PHP Tree Schema?

    Perfect! Thanks,

    -AS

    On May 21, 6:50 am, maruerru <de> wrote: 


    ashore Guest

Similar Threads

  1. Replies: 0
    Last Post: January 29th, 02:03 PM
  2. MySQL schema print utility?
    By Bosconian in forum MySQL
    Replies: 4
    Last Post: December 1st, 07:36 PM
  3. [HELP] retrieve TREE structure from mysql db
    By ghiro in forum PHP Development
    Replies: 1
    Last Post: August 16th, 09:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139