PHP Class Swiftriver\Core\Modules\DataContext\Mongo_V1\Mongo_db

Author: am[at]swiftly[dot]org
显示文件 Open project: ushahidi/Swiftriver-2011

Public Methods

Method Description
__construct ( $host, $port, $user, $pass, $dbname, $persist, $persist_key ) -------------------------------------------------------------------------------- CONSTRUCTOR --------------------------------------------------------------------------------
add_index ( $collection = "", $keys = [], $options = [] ) -------------------------------------------------------------------------------- ADD_INDEX --------------------------------------------------------------------------------
count ( $collection = "" ) -------------------------------------------------------------------------------- COUNT --------------------------------------------------------------------------------
delete ( $collection = "" ) -------------------------------------------------------------------------------- DELETE --------------------------------------------------------------------------------
delete_all ( $collection = "" ) -------------------------------------------------------------------------------- DELETE_ALL --------------------------------------------------------------------------------
drop_collection ( $collection = "" ) -------------------------------------------------------------------------------- DROP COLLECTION --------------------------------------------------------------------------------
get ( $collection = "" ) -------------------------------------------------------------------------------- GET --------------------------------------------------------------------------------
get_where ( $collection = "", $where = [], $limit = 99999 ) -------------------------------------------------------------------------------- GET_WHERE --------------------------------------------------------------------------------
insert ( $collection = "", $data = [] ) -------------------------------------------------------------------------------- INSERT --------------------------------------------------------------------------------
like ( $field = "", $value = "", $flags = "i", $enable_start_wildcard = TRUE, $enable_end_wildcard = TRUE ) -------------------------------------------------------------------------------- LIKE PARAMETERS --------------------------------------------------------------------------------
limit ( $x = 99999 ) -------------------------------------------------------------------------------- LIMIT DOCUMENTS --------------------------------------------------------------------------------
list_indexes ( $collection = "" ) -------------------------------------------------------------------------------- LIST_INDEXES --------------------------------------------------------------------------------
mongo_db ( )
offset ( $x ) -------------------------------------------------------------------------------- OFFSET DOCUMENTS --------------------------------------------------------------------------------
order_by ( $fields = [] ) -------------------------------------------------------------------------------- ORDER BY PARAMETERS --------------------------------------------------------------------------------
remove_all_indexes ( $collection = "" ) -------------------------------------------------------------------------------- REMOVE_ALL_INDEXES --------------------------------------------------------------------------------
remove_index ( $collection = "", $keys = [] ) -------------------------------------------------------------------------------- REMOVE_INDEX --------------------------------------------------------------------------------
select ( $includes = [], $excludes = [] ) -------------------------------------------------------------------------------- SELECT FIELDS --------------------------------------------------------------------------------
switch_db ( $database = '' ) -------------------------------------------------------------------------------- Switch_db --------------------------------------------------------------------------------
update ( $collection = "", $data = [] ) -------------------------------------------------------------------------------- UPDATE --------------------------------------------------------------------------------
update_all ( $collection = "", $data = [] ) -------------------------------------------------------------------------------- UPDATE_ALL --------------------------------------------------------------------------------
where ( $wheres = [] ) -------------------------------------------------------------------------------- WHERE PARAMETERS --------------------------------------------------------------------------------
where_and ( $elements_values = [] ) -------------------------------------------------------------------------------- WHERE AND --------------------------------------------------------------------------------
where_between ( $field = "", $x, $y ) -------------------------------------------------------------------------------- WHERE BETWEEN PARAMETERS --------------------------------------------------------------------------------
where_between_ne ( $field = "", $x, $y ) -------------------------------------------------------------------------------- WHERE BETWEEN AND NOT EQUAL TO PARAMETERS --------------------------------------------------------------------------------
where_gt ( $field = "", $x ) -------------------------------------------------------------------------------- WHERE GREATER THAN PARAMETERS --------------------------------------------------------------------------------
where_gte ( $field = "", $x ) -------------------------------------------------------------------------------- WHERE GREATER THAN OR EQUAL TO PARAMETERS --------------------------------------------------------------------------------
where_in ( $field = "", $in = [] ) -------------------------------------------------------------------------------- WHERE_IN PARAMETERS --------------------------------------------------------------------------------
where_lt ( $field = "", $x ) -------------------------------------------------------------------------------- WHERE LESS THAN PARAMETERS --------------------------------------------------------------------------------
where_lte ( $field = "", $x ) -------------------------------------------------------------------------------- WHERE LESS THAN OR EQUAL TO PARAMETERS --------------------------------------------------------------------------------
where_mod ( $field, $num, $result ) -------------------------------------------------------------------------------- WHERE MOD --------------------------------------------------------------------------------
where_ne ( $field = "", $x ) -------------------------------------------------------------------------------- WHERE NOT EQUAL TO PARAMETERS --------------------------------------------------------------------------------
where_not_in ( $field = "", $in = [] ) -------------------------------------------------------------------------------- WHERE_NOT_IN PARAMETERS --------------------------------------------------------------------------------
where_or ( $field = "", $values ) -------------------------------------------------------------------------------- WHERE OR --------------------------------------------------------------------------------

Private Methods

Method Description
clear ( ) -------------------------------------------------------------------------------- CLEAR --------------------------------------------------------------------------------
connect ( ) -------------------------------------------------------------------------------- CONNECT TO MONGODB --------------------------------------------------------------------------------
connection_string ( $host, $port, $user, $pass, $dbname, $persist, $persist_key ) -------------------------------------------------------------------------------- BUILD CONNECTION STRING --------------------------------------------------------------------------------
where_init ( $param ) -------------------------------------------------------------------------------- WHERE INITIALIZER --------------------------------------------------------------------------------

Method Details

__construct() public method

Automatically check if the Mongo PECL extension has been installed/enabled. Generate the connection string and establish a connection to the MongoDB.
public __construct ( $host, $port, $user, $pass, $dbname, $persist, $persist_key )

add_index() public method

Ensure an index of the keys in a collection with optional parameters. To set values to descending order, you must pass values of either -1, FALSE, 'desc', or 'DESC', else they will be set to 1 (ASC).
public add_index ( $collection = "", $keys = [], $options = [] )

count() public method

Count the documents based upon the passed parameters
public count ( $collection = "" )

delete() public method

delete document from the passed collection based upon certain criteria
public delete ( $collection = "" )

delete_all() public method

Delete all documents from the passed collection based upon certain criteria
public delete_all ( $collection = "" )

drop_collection() public method

Removes the specified collection from the database. Be careful because this can have some very large issues in production!
public drop_collection ( $collection = "" )

get() public method

Get the documents based upon the passed parameters
public get ( $collection = "" )

get_where() public method

Get the documents based upon the passed parameters
public get_where ( $collection = "", $where = [], $limit = 99999 )

insert() public method

Insert a new document into the passed collection
public insert ( $collection = "", $data = [] )

like() public method

Get the documents where the (string) value of a $field is like a value. The defaults allow for a case-insensitive search.
public like ( $field = "", $value = "", $flags = "i", $enable_start_wildcard = TRUE, $enable_end_wildcard = TRUE )
$flags Allows for the typical regular expression flags: i = case insensitive m = multiline x = can contain comments l = locale s = dotall, "." matches everything, including newlines u = match unicode
$enable_start_wildcard If set to anything other than TRUE, a starting line character "^" will be prepended to the search value, representing only searching for a value at the start of a new line.
$enable_end_wildcard If set to anything other than TRUE, an ending line character "$" will be appended to the search value, representing only searching for a value at the end of a line.

limit() public method

Limit the result set to $x number of documents
public limit ( $x = 99999 )

list_indexes() public method

Lists all indexes in a collection.
public list_indexes ( $collection = "" )

mongo_db() public method

public mongo_db ( )

offset() public method

Offset the result set to skip $x number of documents
public offset ( $x )

order_by() public method

Sort the documents based on the parameters passed. To set values to descending order, you must pass values of either -1, FALSE, 'desc', or 'DESC', else they will be set to 1 (ASC).
public order_by ( $fields = [] )

remove_all_indexes() public method

Remove all indexes from a collection.
public remove_all_indexes ( $collection = "" )

remove_index() public method

Remove an index of the keys in a collection. To set values to descending order, you must pass values of either -1, FALSE, 'desc', or 'DESC', else they will be set to 1 (ASC).
public remove_index ( $collection = "", $keys = [] )

select() public method

Determine which fields to include OR which to exclude during the query process. Currently, including and excluding at the same time is not available, so the $includes array will take precedence over the $excludes array. If you want to only choose fields to exclude, leave $includes an empty array().
public select ( $includes = [], $excludes = [] )

switch_db() public method

Switch from default database to a different db
public switch_db ( $database = '' )

update() public method

Update a document into the passed collection
public update ( $collection = "", $data = [] )

update_all() public method

Insert a new document into the passed collection
public update_all ( $collection = "", $data = [] )

where() public method

Get the documents based on these search parameters. The $wheres array should be an associative array with the field as the key and the value as the search criteria.
public where ( $wheres = [] )

where_and() public method

Get the documents where the elements match the specified values
public where_and ( $elements_values = [] )

where_between() public method

Get the documents where the value of a $field is between $x and $y
public where_between ( $field = "", $x, $y )

where_between_ne() public method

Get the documents where the value of a $field is between but not equal to $x and $y
public where_between_ne ( $field = "", $x, $y )

where_gt() public method

Get the documents where the value of a $field is greater than $x
public where_gt ( $field = "", $x )

where_gte() public method

Get the documents where the value of a $field is greater than or equal to $x
public where_gte ( $field = "", $x )

where_in() public method

Get the documents where the value of a $field is in a given $in array().
public where_in ( $field = "", $in = [] )

where_lt() public method

Get the documents where the value of a $field is less than $x
public where_lt ( $field = "", $x )

where_lte() public method

Get the documents where the value of a $field is less than or equal to $x
public where_lte ( $field = "", $x )

where_mod() public method

Get the documents where $field % $mod = $result
public where_mod ( $field, $num, $result )

where_ne() public method

Get the documents where the value of a $field is not equal to $x
public where_ne ( $field = "", $x )

where_not_in() public method

Get the documents where the value of a $field is not in a given $in array().
public where_not_in ( $field = "", $in = [] )

where_or() public method

Get the documents where the value of a $field is in one or more values
public where_or ( $field = "", $values )