PHP Class moadminModel, nodejs-autorestart

Mostra file Open project: shimondoodkin/nodejs-autorestart Class Usage Examples

Public Properties

Property Type Description
$colKeys array Array keys in the first and last object in a collection merged together (used to build sort-by options)
$count integer Number of rows in the entire resultset (before limit-clause is applied)
$mongo MongoDB MongoDB
$sort array Sort array - currently only used for collections
$totalDbSize integer Total size of all the databases

Protected Properties

Property Type Description
$_db Mongo mongo connection - if a MongoDB object already exists (from a previous script) then only DB operations use this

Public Methods

Method Description
__construct ( string $db = null ) Connects to a Mongo database if the name of one is supplied as an argument
createCollection ( string $collection ) Creates a collection
deleteIndex ( string $collection, array $index ) Removes an index
dropCollection ( string $collection ) Drops a collection
dropDb ( ) Drops a database
editObject ( string $collection, string $_id, string $idtype ) : array Retieves an object for editing
ensureIndex ( string $collection, array $indexes, array $unique ) Ensures an index
getStats ( ) : array Generate system info and stats
listCollections ( ) : array Gets a list of database collections
listDbs ( ) : array Gets list of databases
listIndexes ( string $collection ) : array Gets a list of the indexes on a collection
listRows ( string $collection ) : array Get the records in a collection
removeObject ( string $collection, string $_id, string $idtype ) Removes an object from a collection
repairDb ( ) : array Repairs a database
saveObject ( string $collection, string $obj ) : array Saves an object
setDb ( string $db ) Change the DB connection

Protected Methods

Method Description
_exec ( string $cmd ) : mixed Executes a native JS MongoDB command This method is not currently used for anything
_mongo ( ) : Mongo Returns a new Mongo connection
_unserialize ( string $_id, string $idtype ) : mixed Returns a serialized element back to its native PHP form

Method Details

__construct() public method

Connects to a Mongo database if the name of one is supplied as an argument
public __construct ( string $db = null )
$db string

_exec() protected method

Executes a native JS MongoDB command This method is not currently used for anything
protected _exec ( string $cmd ) : mixed
$cmd string
return mixed

_mongo() protected method

Returns a new Mongo connection
protected _mongo ( ) : Mongo
return Mongo

_unserialize() protected method

Returns a serialized element back to its native PHP form
protected _unserialize ( string $_id, string $idtype ) : mixed
$_id string
$idtype string
return mixed

createCollection() public method

Creates a collection
public createCollection ( string $collection )
$collection string

deleteIndex() public method

Removes an index
public deleteIndex ( string $collection, array $index )
$collection string
$index array Must match the array signature of the index

dropCollection() public method

Drops a collection
public dropCollection ( string $collection )
$collection string

dropDb() public method

Drops a database
public dropDb ( )

editObject() public method

Retieves an object for editing
public editObject ( string $collection, string $_id, string $idtype ) : array
$collection string
$_id string
$idtype string
return array

ensureIndex() public method

Ensures an index
public ensureIndex ( string $collection, array $indexes, array $unique )
$collection string
$indexes array
$unique array

getStats() public method

Generate system info and stats
public getStats ( ) : array
return array

listCollections() public method

Gets a list of database collections
public listCollections ( ) : array
return array

listDbs() public method

Gets list of databases
public listDbs ( ) : array
return array

listIndexes() public method

Gets a list of the indexes on a collection
public listIndexes ( string $collection ) : array
$collection string
return array

listRows() public method

Get the records in a collection
public listRows ( string $collection ) : array
$collection string
return array

removeObject() public method

Removes an object from a collection
public removeObject ( string $collection, string $_id, string $idtype )
$collection string
$_id string
$idtype string

repairDb() public method

Repairs a database
public repairDb ( ) : array
return array Success status

saveObject() public method

Saves an object
public saveObject ( string $collection, string $obj ) : array
$collection string
$obj string
return array

setDb() public method

Change the DB connection
public setDb ( string $db )
$db string

Property Details

$_db protected_oe property

mongo connection - if a MongoDB object already exists (from a previous script) then only DB operations use this
protected Mongo $_db
return Mongo

$colKeys public_oe property

Array keys in the first and last object in a collection merged together (used to build sort-by options)
public array $colKeys
return array

$count public_oe property

Number of rows in the entire resultset (before limit-clause is applied)
public int $count
return integer

$mongo public_oe property

MongoDB
public MongoDB $mongo
return MongoDB

$sort public_oe property

Sort array - currently only used for collections
public array $sort
return array

$totalDbSize public_oe property

Total size of all the databases
public int $totalDbSize
return integer