Kitchen Sink: Save and load any type of value in a SQL database

Recommend this page to a friend!
  Info   Documentation   View files (4)   Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 94 All time: 9,445 This week: 343
Version License PHP version Categories
kitchen-sink 1.0Custom (specified...5PHP 5, Databases, Cache
Description Author

This package can Save and load any type of value in a SQL database.

It can store a value of arbitrary type associated with a given key name.

The values are stored in a SQL database table using the serialized value to store in the table.

The package also retrieve or remove an entry by key name.

Picture of Jon Lennryd
  Performance   Level  
Name: Jon Lennryd <contact>
Classes: 1 package by
Country: Sweden Sweden
Age: ???
All time rank: 428928 in Sweden Sweden
Week rank: 713 5 in Sweden Sweden



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:

Examples for Cake 2: (Also found in source file)

// Store an array of data about flowers.
$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.

// 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');

$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');
File Role Description
KitchenSink.php Class Class source
KitchenSinkTable.php Class Class source
LICENSE Lic. License text Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:9,445
This week:343

For more information send a message to info at phpclasses dot org.