public
|
#
__construct( integer $object_id = 0 )
Parameters
- $object_id
- as unique object identifier
|
public
|
|
private
Logger
&
|
|
private
|
#
setErr( $id, $errint_or_response, $additional_msg = '', $http_code = '200' )
|
public
string
|
#
getError( string $id = "master", boolean $raw = false )
return an error msg, empty string if no error
return an error msg, empty string if no error
Parameters
- $id
- of db node
- $raw
- to return JSON answer instead of error string
Returns
string
|
public
|
#
connect( string $id = "", string $server = "localhost:5984", string $user = null, string $pw = null )
fake connect, required for multible hosts and load balancing
sample: $cdb = new CouchDB(); $cdb->connect('cdb1', 'localhost');
fake connect, required for multible hosts and load balancing
sample: $cdb = new CouchDB(); $cdb->connect('cdb1', 'localhost');
Parameters
- $id
- of db node
- $server
- $user
- $pw
|
public
array
|
|
public
array
|
#
getStatistics( )
return a array with statistics about request timings
return a array with statistics about request timings
Returns
array
|
public
array
|
#
show_active_tasks( string $id = "master" )
return all active tasks
Parameters
Returns
array
|
public
string
|
#
http_request( string $id = "master", string $request = '/', mixed $json_data = '', string $type = null )
send a raw user defined JSON request to a CouchDB host and return a raw JSON response from it
send a raw user defined JSON request to a CouchDB host and return a raw JSON response from it
Parameters
- $id
- of db node of host
- $request
- as sample "/_all_dbs"
- $json_data
- JSON or array as sample for binary like array('content_type'=>'image/jpeg','data'=>$binary);
- $type
- GET/POST/PUT/DELETE
Returns
string
|
public
array
|
#
show_databases( string $id = "master" )
return all databases
Parameters
Returns
array
|
public
boolean
|
#
create_database( string $id, string $db_name, integer $revs_limit = null )
create a database
Parameters
- $id
- of db node
- $db_name
- $revs_limit
- see method setRevsLimit for more
Returns
boolean
|
public
boolean
|
#
setRevsLimit( string $id, string $db_name, integer $limit = 1000 )
to reduce the size of the list of old revisions (limits the number of revisions stored in a database). By default it is set to 1000.
to reduce the size of the list of old revisions (limits the number of revisions stored in a database). By default it is set to 1000.
Parameters
- $id
- of db node
- $db_name
- $limit
Returns
boolean
|
public
array
|
#
show_database_status( string $id, string $db_name )
show database informations
show database informations
Parameters
Returns
array
|
public
boolean
|
#
drop_database( string $id, string $db_name )
delete a database
Parameters
Returns
boolean
|
private
|
|
public
string
|
#
getLBNodeId( )
return the last used node id
sample: $cdb->select_rev(null, 'testdb', 'c64263347690285624b135717e034e4a'); if($cdb->getError($cdb->getLBNodeId()) != ''){ print $cdb->getError($cdb->getLBNodeId()); }
return the last used node id
sample: $cdb->select_rev(null, 'testdb', 'c64263347690285624b135717e034e4a'); if($cdb->getError($cdb->getLBNodeId()) != ''){ print $cdb->getError($cdb->getLBNodeId()); }
Returns
string
|
private
|
|
public
array
|
#
lbSelect_all( string & $id, string $db_name, mixed $parameters = null, boolean $include_docs = false )
select all documents
sample: $cdb->lbSelect_all($cid, 'testdb', 'descending=true, limit = 100')
select all documents
sample: $cdb->lbSelect_all($cid, 'testdb', 'descending=true, limit = 100')
Parameters
- $id
- of db node or null to use load balancing (require php session)
- $db_name
- $parameters
- url parameters as array, url string or comma seperated string
- $include_docs
Returns
array
|
public
array
|
#
select_all( string $id, string $db_name, mixed $parameters = null, boolean $include_docs = false )
select all documents
sample: $cdb->select_all('cdb1', 'testdb', 'descending=true, limit = 100')
select all documents
sample: $cdb->select_all('cdb1', 'testdb', 'descending=true, limit = 100')
Parameters
- $id
- of db node
- $db_name
- $parameters
- url parameters as array, url string or comma seperated string
- $include_docs
Returns
array
|
public
array
|
#
lbSelect( string & $id, string $db_name, array $keys, mixed $parameters = null, boolean $include_docs = true )
select documents by key
sample: $cdb->lbSelect($cid, 'testdb', array('c64263347690285624b135717e034b2c', 'c64263347690285624b135717e0345af'), 'descending=true, limit = 100')
select documents by key
sample: $cdb->lbSelect($cid, 'testdb', array('c64263347690285624b135717e034b2c', 'c64263347690285624b135717e0345af'), 'descending=true, limit = 100')
Parameters
- $id
- of db node or null to use load balancing (require php session)
- $db_name
- $keys
- like array('c64263347690285624b135717e034b2c', 'c64263347690285624b135717e0345af', ...);
- $parameters
- url parameters as array, url string or comma seperated string
- $include_docs
Returns
array
|
public
array
|
#
select( string $id, string $db_name, array $keys, mixed $parameters = null, boolean $include_docs = true )
select documents by key
sample: $cdb->select('cdb1', 'testdb', array('c64263347690285624b135717e034b2c', 'c64263347690285624b135717e0345af'), 'descending=true, limit = 100')
select documents by key
sample: $cdb->select('cdb1', 'testdb', array('c64263347690285624b135717e034b2c', 'c64263347690285624b135717e0345af'), 'descending=true, limit = 100')
Parameters
- $id
- of db node
- $db_name
- $keys
- like array('c64263347690285624b135717e034b2c', 'c64263347690285624b135717e0345af', ...);
- $parameters
- url parameters as array, url string or comma seperated string
- $include_docs
Returns
array
|
public
array
|
#
lbSelect_rev( string & $id, string $db_name, string $key, boolean $show_revs = false, string $rev = null, mixed $parameters = null, boolean $include_docs,… )
select a single document
sample: $cdb->lbSelect_rev($cid, 'testdb', 'c64263347690285624b135717e034b2c', true, '18-ba18a8dda1c3484f94c7f150143be8ee')
select a single document
sample: $cdb->lbSelect_rev($cid, 'testdb', 'c64263347690285624b135717e034b2c', true, '18-ba18a8dda1c3484f94c7f150143be8ee')
Parameters
- $id
- of db node or null to use load balancing (require php session)
- $db_name
- $key
- $show_revs
- $rev
- $parameters
- url parameters as array, url string or comma seperated string
- $include_docs,…
Returns
array
|
public
array
|
#
select_rev( string & $id, string $db_name, string $key, boolean $show_revs = false, string $rev = null, mixed $parameters = null, boolean $include_docs,… )
select a single document
sample: $cdb->select_rev('cdb1', 'testdb', 'c64263347690285624b135717e034b2c', true, '18-ba18a8dda1c3484f94c7f150143be8ee')
select a single document
sample: $cdb->select_rev('cdb1', 'testdb', 'c64263347690285624b135717e034b2c', true, '18-ba18a8dda1c3484f94c7f150143be8ee')
Parameters
- $id
- of db node
- $db_name
- $key
- $show_revs
- $rev
- $parameters
- url parameters as array, url string or comma seperated string
- $include_docs,…
Returns
array
|
public
array
|
#
lbView( string & $id, string $db_name, string $design, string $view, mixed $parameters = null )
return a view
sample: $cdb->lbView($cid, 'testdb', 'users', 'names');
return a view
sample: $cdb->lbView($cid, 'testdb', 'users', 'names');
Parameters
- $id
- of db node or null to use load balancing (require php session)
- $db_name
- $design
- $view
- $parameters
- url parameters as array, url string or comma seperated string
Returns
array
|
public
array
|
#
view( string $id, string $db_name, string $design, string $view, mixed $parameters = null )
return a view
sample: $cdb->view('cdb1', 'testdb', 'users', 'names');
return a view
sample: $cdb->view('cdb1', 'testdb', 'users', 'names');
Parameters
- $id
- of db node
- $db_name
- $design
- $view
- $parameters
- url parameters as array, url string or comma seperated string
Returns
array
|
public
boolean
|
#
create_views( string $id, string $db_name, string $design, array $views = null, string $language = 'javascript' )
create a view
Parameters
- $id
- $db_name
- $design
- name
- $views
- like array('all' => array('map'=>'function(doc){ emit(null, doc); }'), 'byName'=>array('map'=>'function(doc){ emit(doc.name, doc); }', 'reduce'=>''))
- $language
- javascript or coffeescript
Returns
boolean
|
public
array
|
#
show_views( string $id, string $db_name, string $design )
return all views of a database design
return all views of a database design
Parameters
- $id
- of db node
- $db_name
- $design
- name
Returns
array
|
public
boolean
|
#
drop_view( string $id, string $db_name, string $design, string $rev = null )
delete all views of a database design
delete all views of a database design
Parameters
- $id
- $db_name
- $design
- name
- $rev
- null to select the last revision or document revision to delete
Returns
boolean
|
public
array
|
#
insert( string $id, string $db_name, mixed $data = '' )
insert a new document and return the document related key, revision, id
sample: $cdb->insert('cdb1', 'testdb', array('date'=>date2MySQLDate()))
insert a new document and return the document related key, revision, id
sample: $cdb->insert('cdb1', 'testdb', array('date'=>date2MySQLDate()))
Parameters
- $id
- of db node
- $db_name
- $data
- array like array('Author'=>'Max', 'PostDate'=>'2014-04-08 10:03:22'); or mixed value (will be stored in fieldname "data") or empty string to create an empty document
Returns
array
|
public
array
|
#
update( string $id, string $db_name, string $key_id, mixed $data, string $rev = null )
update a document and return the document related key, revision, id
sample: $cdb->update('cdb1', 'testdb', 'c64263347690285624b135717e034b2c', array('amount'=>'9.99'), '2-b4d0c1ca7ae4d774bb55efb4b806a1dc');
update a document and return the document related key, revision, id
sample: $cdb->update('cdb1', 'testdb', 'c64263347690285624b135717e034b2c', array('amount'=>'9.99'), '2-b4d0c1ca7ae4d774bb55efb4b806a1dc');
Parameters
- $id
- of db node
- $db_name
- $key_id
- document key/id to update
- $data
- array like array('Author'=>'Max', 'PostDate'=>'2014-04-08 10:03:22'); or mixed value (will be stored in fieldname "data")
- $rev
- document revision to update or null for last revision
Returns
array
|
public
array
|
#
delete( string $id, string $db_name, string $key_id, string $rev = null )
delete a document and return the document related key, revision, id
sample: $cdb->delete('cdb1', 'testdb', 'c64263347690285624b135717e0335ea')
delete a document and return the document related key, revision, id
sample: $cdb->delete('cdb1', 'testdb', 'c64263347690285624b135717e0335ea')
Parameters
- $id
- of db node
- $db_name
- $key_id
- document key/id to update
- $rev
- null to select the last revision or document revision to delete
Returns
array
|
public
array
|
#
deleted( string $id, string $db_name, mixed $parameters = null )
show deleted documents
sample: $cdb->deleted('cdb1', 'testdb')
show deleted documents
sample: $cdb->deleted('cdb1', 'testdb')
Parameters
- $id
- of db node
- $db_name
- $parameters
- url parameters as array, url string or comma seperated string
Returns
array
|
public
array
|
#
compact( string $id, string $db_name, mixed $parameters = null )
compaction compresses the disk database file
sample: $cdb->compact('cdb1', 'testdb')
compaction compresses the disk database file
sample: $cdb->compact('cdb1', 'testdb')
Parameters
- $id
- of db node
- $db_name
- $parameters
- url parameters as array, url string or comma seperated string
Returns
array
|
public
array
|
#
attachment_add( string $id, string $db_name, string $key_id, string $mimetype, string $filename, string $binary, string $rev = null )
add an attachment to a document and return the document related key, revision, id
sample: $cdb->attachment_add('cdb1', 'testdb', 'c64263347690285624b135717e034e4a', 'image/png','logo.png', $bin);
add an attachment to a document and return the document related key, revision, id
sample: $cdb->attachment_add('cdb1', 'testdb', 'c64263347690285624b135717e034e4a', 'image/png','logo.png', $bin);
Parameters
- $id
- of db node
- $db_name
- $key_id
- document key/id to update
- $mimetype
- $filename
- $binary
- $rev
- document revision to update or null for last revision
Returns
array
|
public
string
|
#
attachment_get( string $id, string $db_name, string $key_id, string $filename )
get an attachment of a document and return binary string
sample: $cdb->attachment_get('cdb1', 'testdb', 'c64263347690285624b135717e034e4a', 'logo.png');
get an attachment of a document and return binary string
sample: $cdb->attachment_get('cdb1', 'testdb', 'c64263347690285624b135717e034e4a', 'logo.png');
Parameters
- $id
- of db node
- $db_name
- $key_id
- document key/id to update
- $filename
Returns
string
|
public
array
|
#
attachment_del( string $id, string $db_name, string $key_id, string $filename, string $rev = null )
delete an attachment of a document and return the document related key, revision, id
sample: $cdb->attachment_del('cdb1', 'testdb', 'c64263347690285624b135717e034e4a', 'logo.png');
delete an attachment of a document and return the document related key, revision, id
sample: $cdb->attachment_del('cdb1', 'testdb', 'c64263347690285624b135717e034e4a', 'logo.png');
Parameters
- $id
- of db node
- $db_name
- $key_id
- document key/id to update
- $filename
- $rev
- document revision to update or null for last revision
Returns
array
|