Skip to content

Searches, updates, inserts and deletes on two dimensional array

License

Notifications You must be signed in to change notification settings

spernica/ArrayManager

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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();

About

Searches, updates, inserts and deletes on two dimensional array

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%