Download .zip |
Info | Documentation | View files (4) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2017-06-16 (13 days ago) | Not yet rated by the users | Total: Not yet counted | Not yet ranked |
Version | License | PHP version | Categories | |||
kitchen-sink 1.0 | Custom (specified... | 5 | PHP 5, Databases, Cache |
Description | Author | ||||||||
This package can Save and load any type of value in a SQL database. |
|
Allow you to quickly save and retrieve any type of value in a kitchen_sink mysql table.
The KitchenSink.php is adapted for Cake PHP 2, while the KitchenSinkTable.php is adapted for Cake 3.
This is a 'everything and the kitchen sink' table, where you can store any type of value through Store(). You give your data a key, a unique name, to identify it.
It uses php's serialize() to convert any (well, I guess most) type of php data type and arrays into a serialized string.
Get your data back with a call to Retrieve().
Delete your data with Forget().
You can find a real usage example in this project: https://github.com/Snorvarg/simplicity
Examples for Cake 2: (Also found in source file)
// Store an array of data about flowers.
$this->loadModel('KitchenSink');
$this->KitchenSink->Store("flowers",array('flowers' => 'sweet', 'numbers_in_a_set' => 12));
// Refetch the data from database.
$val = $this->KitchenSink->Retrieve("flowers");
debug($val); // The array of valuable flowers-data.
// Remove from database.
$this->KitchenSink->Forget("flowers");
// Now this will give null.
$val = $this->KitchenSink->Retrieve("flowers");
debug($val); // null, does no longer exist
// Several calls to Store() with same key will overwrite old value.
$this->KitchenSink->Store("Monkeys", array("Messy things in trees."));
$this->KitchenSink->Store("Monkeys", array("Monkeys in the djungle."));
Examples for Cake 3:
$kitchenSink = TableRegistry::get('KitchenSink');
$kitchenSink->Store('apples', array('green', 'red' => 12, 'blue' => array('no!!'), 'yellow' => 2));
$appleInfo = $kitchenSink->Retrieve('apples');
$kitchenSink->Forget('apples');
$whatApples = $kitchenSink->Retrieve('apples'); // Returns null.
$nullIfNotThere = $kitchenSink->Retrieve('FancyKey');
// This is a nice shortcut to give a default value if there is none in database.
$alwaysDefined = $kitchenSink->Retrieve('ScreaminglyFancyKey', 'a default value here');
Files |
File | Role | Description |
---|---|---|
KitchenSink.php | Class | Class source |
KitchenSinkTable.php | Class | Class source |
LICENSE | Lic. | License text |
README.md | Doc. | Documentation |
Version Control | Unique User Downloads | |||||||
100% |
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.