objectstore

  • JSON, JSON, Everywhere

    JSON stands for JavaScript Object Notation, and if you dig through the source, you'll quickly realize that JSON is the preferred format of choice for FlowBasis. JSON is easily usable from client-side javascript or within PHP on the server. It's the format objects are transmitted in from the client to the server and back again for remote procedure calls (AJAX stuff), and it's the format of objects saved in the FlowBasis object store.

    A sample JSON object declaration might look like (in Javascript, the quotes aren't required around "username" or "favoriteNumbers"):

    { "username" : "bob", "favoriteNumbers" : [42, 37, 100] }

    In PHP, this could be declared as:

    $bob = new stdClass;
    $bob->username = "bob";
    $bob->favoriteNumbers = array(42, 37, 100);

    and it could be converted to JSON with:

    $json = json_encode($bob);

    But, usually, the FlowBasis infrastructure will convert the PHP object into JSON where needed.

    No comments.
    AverageNot yet rated.
    Your Rating
  • Look, Ma! No SQL!

    Rather than rely on a SQL server for tracking users, blog posts, and such, FlowBasis uses a JSON object store for persisting, retrieving, and updating objects (see FlowBasis_Data_FileObjectStore for implementation). Relational databases have any number of niceties, including being well-understood, well-tested, and providing a known structure for data. However, databases are frequently very slow in shared hosting environments and mapping the objects we tend to use as programmers to relatational tables can be tedious. While the merits of SQL databases versus the free-form object store could be debated at length, I'll leave it at that for now.

    The object store provides a few basic methods: getObject, saveObject, and updateObject. Beyond that, there are a few additional methods for retrieving lists of objects and locking objects for synchronization. The default implementation of FlowBasis_Data_IObjectStore saves and loads everything to and from the file system, but the door is open for future implementations which use a database or the "cloud" for storage (though I imagine more intelligent use of caching would become necessary as the object store moves farther away from the local server).

    All that said, if you really want to use SQL with FlowBasis, you're welcome to use it. FlowBasis incorporates the open-source adodb library and provides a management panel for configuring connections and trying out SQL queries.

    No comments.
    Average
    Your Rating