Code Monkey home page Code Monkey logo

arraymanager's Introduction

Mesour ArrayManager

Searches, updates, inserts and deletes on two dimensional array

Install

  • With Composer

      "require": {
          "mesour/array-manager": "~0.0.2"
      }
    

Example array

$your_array = array(
    array('name' => 'John', 'surname' => 'Doe', 'email' => '[email protected]'),
    array('name' => 'John', 'surname' => 'Larson', 'email' => '[email protected]'),
    array('name' => 'Claude', 'surname' => 'Graves', 'email' => '[email protected]'),
    array('name' => 'Stuart', 'surname' => 'Norman', 'email' => '[email protected]'),
    array('name' => 'Kathy', 'surname' => 'Arnold', 'email' => '[email protected]'),
    array('name' => 'Jan', 'surname' => 'Wilson', 'email' => '[email protected]'),
    array('name' => 'Alberta', 'surname' => 'Erickson', 'email' => '[email protected]'),
    array('name' => 'Ada', 'surname' => 'Wells', 'email' => '[email protected]'),
    array('name' => 'Ethel', 'surname' => 'Figueroa', 'email' => '[email protected]'),
    array('name' => 'Ian', 'surname' => 'Goodwin', 'email' => '[email protected]'),
);

Select

$manager = new \Mesour\ArrayManager($your_array);

$select = $manager->select();

//set keys sensitive to TRUE (default is FALSE)
\Mesour\ArrayManage\Searcher\Condition::setKeysSensitive();

$select->column('*', 'name')
	->where('name', 'John', \Mesour\ArrayManage\Searcher\Condition::EQUAL, 'or')
	->where('name', 'Max', \Mesour\ArrayManage\Searcher\Condition::EQUAL, 'or')
	->where('email', '.xx', \Mesour\ArrayManage\Searcher\Condition::END_WITH, 'and')
	->limit(10)
	->offset(1)
	->orderBy('name', 'ASC');

print_r($select->fetchAll());

print($select->count());

Update

$manager = new \Mesour\ArrayManager($your_array);

$manager->update(array(
	'name' => 'Matouš'
))
->where('name', 'John', \Mesour\ArrayManage\Searcher\Condition::EQUAL)
	->execute();

print_r($your_array); // updated array

Insert

$manager = new \Mesour\ArrayManager($your_array);

$manager->insert(array(
	'name' => 123
))->execute();

print_r($your_array); // updated array

Delete

$manager = new \Mesour\ArrayManager($your_array);

$manager->delete()
	->where('name', 'John', \Mesour\ArrayManage\Searcher\Condition::EQUAL)
	->execute();

print_r($your_array); // updated array

Test

$manager = new \Mesour\ArrayManager($your_array);

$select = $manager->select();

$select->test();

arraymanager's People

Contributors

mesour avatar mesourcz avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

arraymanager's Issues

Integrating CI building service

As title, I think it's good to integrate the CI building service to do unit tests work automatically.

And it can be good to use GitHub Action to accomplish this issue.

Initial tests

As title, I think it should be good to initial unit tests with PHPUnit :).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.