承接 byjg/anydataset-array 相关项目开发

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

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

byjg/anydataset-array

最新稳定版本:5.0.1

Composer 安装命令:

composer require byjg/anydataset-array

包简介

Anydataset Array abstraction. Anydataset is an agnostic data source abstraction layer in PHP.

README 文档

README

Build Status Opensource ByJG GitHub source GitHub license GitHub release

Array abstraction dataset. Anydataset is an agnostic data source abstraction layer in PHP.

See more about Anydataset here.

Examples

Simple Manipulation

<?php
$array = ["A", "B", "C"];

$dataset = new \ByJG\AnyDataset\Lists\ArrayDataset($array);

$iterator = $dataset->getIterator();
foreach ($iterator as $row) {
    echo $row->get('__id');     // Print 0, 1, 2
    echo $row->get('__key');    // Print 0, 1, 2
    echo $row->get('value');    // Print "A", "B", "C"
}

Associative Arrays

<?php
$array = ["A" => "ProdA", "B" => "ProdB", "C" => "ProdC"];

$dataset = new \ByJG\AnyDataset\Lists\ArrayDataset($array);

$iterator = $dataset->getIterator();
foreach ($iterator as $row) {
    echo $row->get('__id');     // Print 0, 1, 2
    echo $row->get('__key');    // Print "A", "B", "C"
    echo $row->get('value');    // Print "ProdA", "ProdB", "ProdC"
}

Array of objects

<?php
class Name {
    public $name;
    public $surname;

    public function __construct($name, $surname) {
        $this->name = $name;
        $this->surname = $surname;
    }
}
$array = [
    "A" => new Name("Joao", "Gilberto"),
    "B" => new Name("John", "Doe"),
    "C" => new Name("Mary", "Jane")
];

$dataset = new \ByJG\AnyDataset\Lists\ArrayDataset($array);

$iterator = $dataset->getIterator();
foreach ($iterator as $row) {
    echo $row->get('__id');     // Print 0, 1, 2
    echo $row->get('__key');    // Print A, B, C
    echo $row->get('__class');  // Print \Name
    echo $row->get('name');     // Print "Joao", "John", "Mary"
    echo $row->get('surname');  // Print "Gilberto", "Doe", "Jane"
}

Filtering results

<?php
class Name {
    public $name;
    public $surname;

    public function __construct($name, $surname) {
        $this->name = $name;
        $this->surname = $surname;
    }
}
$array = [
    "A" => new Name("Joao", "Gilberto"),
    "B" => new Name("John", "Doe"),
    "C" => new Name("Mary", "Jane")
];

$dataset = new \ByJG\AnyDataset\Lists\ArrayDataset($array);

$filter = new \ByJG\AnyDataset\Core\IteratorFilter();
$filter->addRelation("surname", \ByJG\AnyDataset\Core\Enum\Relation::EQUAL, "Doe");
$iterator = $dataset->getIterator($filter);
foreach ($iterator as $row) {
    echo $row->get('__id');     // Print 1
    echo $row->get('__key');    // Print B
    echo $row->get('__class');  // Print \Name
    echo $row->get('name');     // Print "John"
    echo $row->get('surname');  // Print "Doe"
}

Install

Just type:

composer require "byjg/anydataset-array"

Running Unit tests

vendor/bin/phpunit

Dependencies

flowchart TD
    byjg/anydataset-array --> byjg/anydataset
Loading

Open source ByJG

统计信息

  • 总下载量: 77.58k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固