 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
DZone.com: The era of Object-Document Mapping
by Chris Cornutt July 08, 2011 @ 11:45:46
On the PHP on Windows section of DZone.com today Giorgio Sironi has posted about a different sort of object mapping than is usually thought of with databases - object-document mapping.
The Data Mapper pattern is a mechanism for persistence where the application model and the data source have no dependencies between each other. [...] But everytime we talk about the Data Mapper pattern, we assume there is a relational database on the other side of the persistence boundary. We always save objects; we always map them to MySQL or Postgres tables; but it's not mandatory.
He talks about two projects, MongoDb_ODM and CouchDb_ODM, that the Doctrine project is working on to help make working with document-driven databases as simple as the usual ORMs. He includes a brief code snippet showing how the feature will work (hint: a namespace of Document instead of Entity). He lists some of the features - including the usual ORM capabilities, support for collections, cascade of persistence - and where you can get the latest code for it (from github and PEAR
voice your opinion now!
object document mapping doctrine mongodb couchdb
DZone.com: Using a stream wrapper to access CouchDb attachments with PHP
by Chris Cornutt April 28, 2011 @ 10:45:27
On DZone.com today there's a new post from Gonzalo Ayuso about using a stream wrapper to access CouchDb database directly from PHP (via a call to its local file).
Thanks to a comment in my last post (many thanks Benjamin) I've discovered that it's possible to create a stream wrapper in PHP (I thought it was only available with a C extension). It's pretty straightforward to create the wrapper. Of course it's only an approach. We can create more functionality to our stram wrapper but at least this example meets my needs.
His wrapper uses a client from his Nov framework to open the stream to the given path and gives read and write methods to work with the data inside the database. Code for the wrapper class is included as well as a bit of example code showing how it can be used with the custom stream protocol. You can find the complete code here.
voice your opinion now!
couchdb stream wrapper database tutorial
Gonzalo Ayuso's Blog: Using a stream wrapper to access CouchDb attachments with PHP
by Chris Cornutt September 06, 2010 @ 08:15:22
In his continuing look at using CouchDb as a file system, Gonzalo Ayuso has posted this third part in the group of articles about using streams to connect your scripts to the database instance.
I'm still working in my filesystem with CouchDb. After creating a library to enable working with PHP and CouchDB (see the post here), and after using Monkey Patching to override standard PHP's filesystem functions. I've created another solution now. Thanks to a comment in my last post (many thanks Benjamin) I've discovered that it's possible to create a stream wrapper in PHP (I thought it was only available with a C extension).
He includes the code for the stream connection wrapper, a pretty simple script that parses the string it's given and opens a read/write stream to the source. There's also a "url_stat" method that will return to you the size of the stream in bytes. Then you just register the wrapper and go about your normal file system calls to use the CouchDb directly.
voice your opinion now!
couchdb stream wrapper attachment tutorial
Gonzalo Ayuso's Blog: Using Monkey Patching to store files in CouchDb using the standard filesystem
by Chris Cornutt September 02, 2010 @ 14:10:12
Gonzalo Ayuso takes his "CouchDb as a filesystem" approach one step further (see the previous post about it here) with this new post talking about monkey patching to store files into the CouchDb server using the normal PHP file handling functions.
Since PHP5.3 a new design pattern is available for us: Monkey Patching. With this pattern we can override PHP's core functions with a home-made functions in a different namespace (another example here). That's means if I have fopen function in the above example, PHP uses the filesystem function "fopen" but if we set a namespace in our example, PHP will search first the function within the current namespace.
By defining the new interface inside of a namespace (with functions to override the default PHP file handlers) you can have the rest of the code call the same functions (fopen, fread, etc) but they'll do different things. In this case it handles them as push and pull to the CouchDb instead of the normal filesystem. You can grab the source for this example here.
voice your opinion now!
monkeypatching namespace filesystem couchdb tutorial
Gonzalo Ayuso's Blog: Using CouchDb as filesystem with PHP
by Chris Cornutt September 01, 2010 @ 13:41:12
In a new post to his blog Gonzalo Ayuso shows an interesting use for the CouchDB tool - using it as a filesystem for cross-server handling of things like images or other binary resources.
One of the problems I need to solve in my clustered PHP applications is where to store files. When I say files I'm not speaking about source code. I'm speaking about additional data files, such as download-able pdfs, logs, etc. Those files must be on every node of the cluster. [...] CouchDb has two great features to meet or requirements with this problem. It allows us to store files as attachments and it also allows to perform a great and very easy multi-master replica system.
He shows how use two libraries he's created to connect to the CouchDB instance and, based on this structure, be able to insert the content - a text file in this case - pull it back out, get the meta data about it and even move it to another location in the structure.
voice your opinion now!
couchdb filesystem tutorial binary file
Gonzalo Ayuso's Blog: PHP and couchDB
by Chris Cornutt March 16, 2010 @ 13:55:22
In a recent post to his blog Gonzalo Ayuso has a brief introduction to CouchDB and how you can use it in your application. Most of the post is made up of code samples showing some of the basic relational database operations translated over to a CouchDB database (found in this class).
I come from relational database world. NoSQL is new for me. Maybe I'm wrong but I want to use INSERT, UPDATE, DELETE and SELECT statements in CouchDB in the same way I use them in Relational database. The class is focused in the HTTP Document API. There is a great tutorial here that explains the API. Now I'll show the interface I've made to perform the statements with CouchDB.
There's examples of both simple and more complex selects, updates and deletes as well as the handling of exceptions via two types he's included support for - NoDataFound and DupValOnIndex.
voice your opinion now!
couchdb interface nosql rdbms
|
Community Events
Don't see your event here? Let us know!
|