Skip to content

I have a problem with method get_nested() #12

Description

@devsantoshm

Hi Sir, you're awesome teaching in this course, but I have a problem in the file page_m.php with the method get_nested(), when i have my records in phpmyadmin of this manner

id title .... parent_id
1 homepage ... 0
5 contact ... 6
6 about ... 0

in the method get_nested(), just back array only with parent_id=0, but not the children:

Dump => array(2) {
[1] => array(6) {
["id"] => string(1) "1"
["title"] => string(8) "Homepage"
["slug"] => string(1) "/"
["order"] => string(1) "1"
["body"] => string(241) "Multiple function calls can be made if you need several joins in one query.
If you need a specific type of JOIN you can specify it via the third parameter of the function. Options are: left, right, outer, inner, left outer, and right outer."
["parent_id"] => string(1) "0"
}
[6] => array(6) {
["id"] => string(1) "6"
["title"] => string(5) "about"
["slug"] => string(5) "about"
["order"] => NULL
["body"] => string(46) "

esta página about

"
["parent_id"] => string(1) "0"
}
}
but, If I change the order of my records in phpmyadmin

id title .... parent_id
1 homepage ... 0
5 contact ... 0
6 about ... 5

I get the children

Dump => array(2) {
[1] => array(6) {
["id"] => string(1) "1"
["title"] => string(8) "Homepage"
["slug"] => string(1) "/"
["order"] => string(1) "1"
["body"] => string(241) "Multiple function calls can be made if you need several joins in one query.
If you need a specific type of JOIN you can specify it via the third parameter of the function. Options are: left, right, outer, inner, left outer, and right outer."
["parent_id"] => string(1) "0"
}
[5] => array(7) {
["id"] => string(1) "5"
["title"] => string(7) "contact"
["slug"] => string(7) "contact"
["order"] => NULL
["body"] => string(36) "

nbuevo ontenido

"
["parent_id"] => string(1) "0"
["children"] => array(6) {
["id"] => string(1) "6"
["title"] => string(5) "about"
["slug"] => string(5) "about"
["order"] => NULL
["body"] => string(46) "

esta página about

"
["parent_id"] => string(1) "5"
}
}
}

How can I resolve this problem?

Regards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions