$org = new @ref TSDStandardOrganization "TSDStandardOrganization"(2);
If you already have a node and you want to get its children, you can call listChildren() on that node. This method will return a list of nodes that belong to the given node. So, if you have a grade and want a list of all categories in it, you can do the following:
// get the grade object $grade = new @ref TSDStandardGrade "TSDStandardGrade"(14); // get an array of child objects $children = $grade->@ref TSDStandardGrade::listChildren "listChildren"(); // prints the name of the first category returned print $children[0]->name;
You can control which children are returned and how many are returned with additional arguments to listChildren(). These types of arguments are explained in the Guide to Database Constraints.
All node classes additional have a static method called getList() which will return a list of objects of that type. If you want to retrieve a list of all organizations, you could do the following:
$organizations = TSDStandardOrganization::getList(); foreach($organizations as $org) print "Organization: $org->name<br />";
All non-root nodes have a getParent() method which returns an object representing the parent, or containing, node. If you have a grade object, you can call getParent() to get the organization that that grade belongs to:
$grade = new TSDGrade(24);
$org = $grade->getParent();
First method, for root nodes:
// create the empty object first $org = new @ref TSDStandardOrganization "TSDStandardOrganization"() // fill in details (but not the ID, this will be done automatically) $org->name = 'My Organization'; $org->state = 'NC'; // commit the new organization to the database $org->commit();
For non-root nodes, the following method must be used:
// get the parent node $grade = new @ref TSDStandardGrade "TSDStandardGrade"(47); // create the new category $cat = $grade->@ref TSDStandardGrade::addCategory "addCategory"('My Category');
1.5.6