Coeus Framework  1.0
Public Member Functions
model_functions Class Reference

Model Class Functions. More...

Inheritance diagram for model_functions:
model

Public Member Functions

 addNew ()
 Adds a new (blank) document with a new _id. More...
 
 save ()
 Saves the current document as is. More...
 
 remove ()
 Removes the current document. More...
 
 find ($filter=[], $options=[])
 Finds document(s) based on filters and options. More...
 
 next ()
 Moves to the next document cursor. More...
 
 getAll ( $json=false)
 Returns all documents within the cursor. More...
 
 getCurrent ()
 Returns the current document. More...
 
 getId ( $idStr)
 Returns the BSON object _id. More...
 
 __set ($name, $value)
 
__get ($name)
 
 json ( $object)
 Returns an object as a JSON string. More...
 

Detailed Description

Model Class Functions.

This database model uses MongoDB as its backend. In that reguard, every table is a "collection" and every record is a "document." You must specify your "Schema" in your child class.

Author
David A. Lamkin dlamk.nosp@m.in@c.nosp@m.oupon.nosp@m.wall.nosp@m.et.co.nosp@m.m
Version
1.0
Todo:

Add user/password security

Add create database

Member Function Documentation

◆ addNew()

addNew ( )

Adds a new (blank) document with a new _id.

Warning
You must save after inputting data.
Returns
$this

◆ find()

find (   $filter = [],
  $options = [] 
)

Finds document(s) based on filters and options.

Parameters
array$filterAn array of filters
array$optionsSet Query options ie('sort', etc.)
Filter Example:
$this->find(['first_name' => 'Joe']);
Options Example:
// Return ONLY the _id field
$this->find([], ['projection' => ['_id' => 1]]);

◆ getAll()

getAll (   $json = false)

Returns all documents within the cursor.

Parameters
boolean$jsonSpecify the output to be json (rather than an object)
Returns
object
Warning
Be careful you don't return a million documents. It may be better to just iterate through the document cursor

◆ getCurrent()

getCurrent ( )

Returns the current document.

Returns
object

◆ getId()

getId (   $idStr)

Returns the BSON object _id.

THis is usually used for searching by _id.

Parameters
string$idStrId of the document in string format
Returns
object

◆ json()

json (   $object)

Returns an object as a JSON string.

Parameters
object$object
Returns
string

◆ next()

next ( )

Moves to the next document cursor.

Returns
$this

◆ remove()

remove ( )

Removes the current document.

Returns
$this

◆ save()

save ( )

Saves the current document as is.

Returns
$this
Exceptions
errorError on failure

The documentation for this class was generated from the following file: