Stash

I created my Stash classes and functions as an easy way to stash object data.

The classes were designed with multiple methods of storing data in mind, so that storing data to an XML file would be no more complicated to a developer than storing in a DB, and use the same method calls.

I have made the classes available to the public, including the code to store to a MySQL database. I wrote the code to store to a couple of other formats (XML, YAML) but as these were used in commercial products I unfortunately cannot make them open source.

I eventually abandoned further development of these classes as I generally use Doctrine ORM, however these classes are lightweight and suitable for small projects or those where performance is important.

The classes comprise of three parts:

  • SQL query builder
  • Bean class for individual objects
  • Collection class that works with collections of objects

Query Builder

The query builder makes creating queries easy. Parts of the query can be specified in any order, and are specified using methods, like this:

Stash Bean

The stash bean has several useful methods, such as retrieve(), save(), update() etc. which interact with the DB (or other storage mechanism)

By default the class generates UUIDs for object ids. You can change this by overloading the create_id() method. (e.g. make create_id() return null if you are using an auto-incrementing integer)

A useful feature of the bean is archiving.

Stash Collection

The collection class allows you to work with a collection of objects. For example, fetching documents created in a specific time:

Download

You can download the classes, with an example of how to use them, here

Full API documentation for the stash classes is available in the API Docs

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">