承接 ben-nsng/nestedset-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ben-nsng/nestedset-php

Composer 安装命令:

composer require ben-nsng/nestedset-php

包简介

A PDO plugin implementing the nested set pattern

README 文档

README

If you are not using any PHP framework and need to manage tree structure data, here is the library using Nested Sets Pattern to Model Tree Structure in PHP

Installation

To install the library, you can simply clone the library and include the file pdo.nestedset.php. If you are using Composer in your project, it is really simple to install nestedset-php.

# Install Composer
curl -sS https://getcomposer.org/installer | php

# Add nestedset-php as a dependency
php composer.phar require ben-nsng/nestedset-php:*

Usage

$pdo = new PDO('mysql:host=localhost;dbname=tree', 'tree', 'tree');
$treeModel = new NestedSet($pdo);
$treeModel->changeTable('tree'); // default table is tree

API

Instance methods:

// init table for first creating table
$treeModel->addRoot();

// add new node to root node, return node id
$treeModel->addNode($label);

// add new node into parent node return node id
$treeModel->addNode($label, $parent_id);

// return database statement object
$nodes = $treeModel->selectAll();
// array of nodes (stdclass)
$nodes->result();

// move existing node into parent node
$treeModel->addChild($node_id, $parent_id);

// move existing node before next node
$treeModel->addBefore($node_id, $next_id);

// move existing node after last node
$treeModel->addBefore($node_id, $last_id);

// delete existing node, including nodes inside node
$treeModel->deleteNode($node_id)

Related Links/Resources

Authors

统计信息

  • 总下载量: 8.94k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 23
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 23
  • Watchers: 6
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固