bartko-s / stefano-tree

Framework agnostic Nested Set (MPTT) implementation for PHP
https://bartko-s.github.io/stefano-tree
BSD 3-Clause "New" or "Revised" License
28 stars 8 forks source link

A Typical Data Field and Value for a Node #15

Closed philecom closed 5 years ago

philecom commented 5 years ago

I've been trying to integrate this library into Joomla components. My actual struggle is; for an example taking the following code from the documentation:

` try { $data = array( // values // id_column_name => uuid );

 // create root node.
 $rootNodeId = $tree->createRootNode($data);  
 // create root node. Second param "$scope" is required only if scope support is enabled.
 $rootNodeId = $tree->createRootNode($data, $scope);    
 } catch (ValidationException $e) {
 $errorMessage = $e->getMessage();
  } `

what is going to be the values for this section $data = array( // values // id_column_name => uuid );

if my database table has these columns 'tableName' => 'vz0q4_users', 'idColumnName' => 'id', 'sequenceName' => 'categories', 'scopeColumnName' => 'scope', 'leftColumnName' => 'lft', 'rightColumnName' => 'rght', 'levelColumnName' => 'level', 'parentIdColumnName' => 'parent_id'

Thank you.

bartko-s commented 5 years ago

Which database are you using postgres or mariadb? For primary key are you using autoincrement or sequence or uuid? Do you want to insert into table more then one independent tree structure?

philecom commented 5 years ago

@bartko-s I'm using MySQL(MariaDB) I'm using autoincrement as a primary key I'm currently inserting into one tree; but would be happy to know how to insert into multiple independent tree structure

bartko-s commented 5 years ago

Then:

$tree = new NestedSet($options, $dbAdapter);

philecom commented 5 years ago

@bartko-s I got that part. what my issue is the content of "values" in the $data array

`$data = array( // values // id_column_name => uuid );

$rootNodeId = $tree->createRootNode($data); `

philecom commented 5 years ago

@bartko-s I dont know why you close this issue when the problem has not been solved

bartko-s commented 5 years ago

This is not issue. This is only question. The content of $data is values which you want to insert into database row exlude primary_key(is generated by database autoincrement), left, right, level, scope, parent_id. See example