Data-mullet is a NoSQL-style API for SQL databases
- Data-mullet Home Page
- Note: Users of the CouchDB-PHP combo will have to download and include the required library files for CouchDB to work with PHP. They can be found here. The requires files are lib/couch.php, lib/couchClient.php, and lib/couchDocument.php.
str = POST("https://user:[email protected]/users/stuff/_insert'",
params = {'docs' : '[{"x" : "1"}]'},
async = False )
curl -X POST -u user:pwd --data 'docs=[{"x":1}]' 'https://datamullet.com/users/stuff/_insert'
$conn = new Mullet;
$coll = $conn->users->stuff;
$doc = array(
"x" => 1
);
$coll->insert( $doc );
tar xvzf datamullet-0.1.tar.gz
cd datamullet-0.1
cp Mullet.php /path/to/htdocs/
Local:
To connect to a local PostgreSQL database:
BEFORE you include/require 'Mullet.php' add these lines:
define( 'DATABASE_NAME', 'my_data' );
define( 'DATABASE_ENGINE', 'pgsql' ); // or mysql, mongodb, pgsql, couchdb, sqlite
define( 'DATABASE_USER', 'ben' );
define( 'DATABASE_PASSWORD', '' );
define( 'DATABASE_HOST', '' );
define( 'DATABASE_PORT', 5432 );
Remote:
If you want to set up the HTTP api, here is a .htaccess file that only works witha domain or subdomain (you will need a better .htaccess file to use the Data-mullet HTTP api [[[[ in a subfolder ]]]]).
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !^/index.php
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.+)$ /index.php/$1
What we're working on:
- Create some documentation
- Set up a wiki
- Contribute to http://datamullet.posterous.com
curl -X GET -u user:pwd 'http://example/_hello'
curl -X GET -u user:pwd 'http://example/_all_dbs'
curl -X PUT -u user:pwd 'http://example/mydb'
curl -X POST -u user:pwd --data 'docs=[{"x":1}]' 'http://example/mydb/mystuff/_insert'
curl -X GET -u user:pwd 'http://example/mydb/mystuff/_find'
curl -X POST -u user:pwd --data 'criteria=[{"x":1}]&newobj=[{"x":2}]' 'http://example/mydb/mystuff/_update'
curl -X POST -u user:pwd --data 'criteria=[{"x":1}]' 'http://example/mydb/mystuff/_remove'
$conn = new Mullet(); $conn = new Mullet('sqlite:/var/www/file');
$coll = $conn->mydb->mystuff;
insert document into database and create tables (mydb_mystuff) and fields (followers,profile,bookmarks)
$doc = array( "followers" => 1, "profile" => (object)array( "name" => "Fremont", "id" => 102 ), "bookmarks" => array( 09386, 5204785, 938175 ) ); $coll->insert( $doc );
$coll->findOne();
$coll->update( array( 'x' => 1 ), array( 'x' => 2 ));
$coll->remove( array( 'x' => 1 ));
$cursor = $coll->find(array( "x" => 1 ));
foreach ($cursor as $id => $value) {
echo "$id: ";
var_dump( $value );
}
$query = array( "x" => 1 );
$cursor = $coll->find( $query );
while( $cursor->hasNext() )
var_dump( $cursor->getNext() );