public
|
|
public static
Maslosoft\Mangan\Interfaces\EntityManagerInterface
|
#
create( Maslosoft\Addendum\Interfaces\AnnotatedInterface $model, Maslosoft\Mangan\Mangan $mangan = null )
Create model related entity manager.
This will create customized entity manger if defined in model with EntityManager annotation.
If no custom entity manager is defined this will return default EntityManager.
Create model related entity manager.
This will create customized entity manger if defined in model with EntityManager annotation.
If no custom entity manager is defined this will return default EntityManager.
Parameters
Returns
|
public
|
#
setAttributes( mixed[] $atributes )
Set attributes en masse.
Attributes will be filtered according to SafeAnnotation.
Only attributes marked as safe will be set, other will be ignored.
Set attributes en masse.
Attributes will be filtered according to SafeAnnotation.
Only attributes marked as safe will be set, other will be ignored.
Parameters
|
public
boolean
|
#
insert( Maslosoft\Addendum\Interfaces\AnnotatedInterface $model = null )
Inserts a row into the table based on this active record attributes.
If the table's primary key is auto-incremental and is null before insertion,
it will be populated with the actual value after insertion.
Inserts a row into the table based on this active record attributes.
If the table's primary key is auto-incremental and is null before insertion,
it will be populated with the actual value after insertion.
Note, validation is not performed in this method. You may call validate to perform the validation.
After the record is inserted to DB successfully, its isNewRecord property will be set false,
and its scenario property will be set to be 'update'.
Parameters
- $model
- if want to insert different model than set in constructor
Returns
boolean whether the attributes are valid and the record is inserted successfully.
Throws
Since
v1.0
Implementation of
|
public
boolean
|
#
update( array $attributes = null )
Updates the row represented by this active document.
All loaded attributes will be saved to the database.
Note, validation is not performed in this method. You may call validate to perform the validation.
Updates the row represented by this active document.
All loaded attributes will be saved to the database.
Note, validation is not performed in this method. You may call validate to perform the validation.
Parameters
- $attributes
list of attributes that need to be saved. Defaults to null,
meaning all attributes that are loaded from DB will be saved.
Returns
boolean whether the update is successful
Throws
Since
v1.0
Implementation of
|
public
|
#
updateOne( array|Maslosoft\Mangan\Interfaces\CriteriaInterface $criteria = null, array $attributes = null, boolean $modify = false )
Updates one document with the specified criteria and attributes
Updates one document with the specified criteria and attributes
This is more raw update:
- Does not raise any events or signals
- Does not perform any validation
Parameters
- $criteria
- query criteria.
- $attributes
- list of attributes that need to be saved. Defaults to null,
- $modify
tu force update/upsert document
meaning all attributes that are loaded from DB will be saved.
Since
v1.0
Implementation of
|
public
boolean
|
|
public
boolean
|
#
replace( boolean $runValidation = true )
Replaces the current document.
Replaces the current document.
NOTE: This will overwrite entire document.
Any filtered out properties will be removed as well.
The record is inserted as a documnent into the database collection, if exists it will be replaced.
Validation will be performed before saving the record. If the validation fails,
the record will not be saved. You can call getErrors() to retrieve the
validation errors.
Parameters
- $runValidation
whether to perform validation before saving the record.
If the validation fails, the record will not be saved to database.
Returns
boolean whether the saving succeeds
Since
v1.0
Implementation of
|
public
boolean
|
#
save( boolean $runValidation = true )
Saves the current document.
Saves the current document.
The record is inserted as a document into the database collection or updated if exists.
Filtered out properties will remain in database - it is partial safe.
Validation will be performed before saving the record. If the validation fails,
the record will not be saved. You can call getErrors() to retrieve the
validation errors.
Parameters
- $runValidation
whether to perform validation before saving the record.
If the validation fails, the record will not be saved to database.
Returns
boolean whether the saving succeeds
Since
v1.0
Implementation of
|
public
boolean
|
#
upsert( boolean $runValidation = true )
Updates or inserts the current document. This will try to update existing fields.
Will keep already stored data if present in document.
Updates or inserts the current document. This will try to update existing fields.
Will keep already stored data if present in document.
If document does not exist, a new one will be inserted.
Parameters
Returns
boolean
Throws
Implementation of
|
public
boolean
|
#
refresh( )
Reloads document from database.
It return true if document is reloaded and false if it's no longer exists.
Reloads document from database.
It return true if document is reloaded and false if it's no longer exists.
Returns
boolean
Implementation of
|
public
boolean
|
#
delete( )
Deletes the document from database.
Deletes the document from database.
Returns
boolean whether the deletion is successful.
Throws
Implementation of
|
public
|
#
deleteOne( array|Maslosoft\Mangan\Interfaces\CriteriaInterface $criteria = null )
Deletes one document with the specified primary keys.
Does not raise beforeDelete
See find() for detailed explanation about $condition and $params.
Deletes one document with the specified primary keys.
Does not raise beforeDelete
See find() for detailed explanation about $condition and $params.
Parameters
- $criteria
- query criteria.
Since
v1.0
Implementation of
|
public
|
#
deleteByPk( mixed $pkValue, array|Maslosoft\Mangan\Interfaces\CriteriaInterface $criteria = null )
Deletes document with the specified primary key.
See find() for detailed explanation about $condition and $params.
Deletes document with the specified primary key.
See find() for detailed explanation about $condition and $params.
Parameters
- $pkValue
- primary key value(s). Use array for multiple primary keys. For composite key, each key value must be an array (column name=>column value).
- $criteria
- query criteria.
Since
v1.0
Implementation of
|
public
boolean
|
#
deleteAllByPk( mixed[] $pkValues, array|Maslosoft\Mangan\Interfaces\CriteriaInterface $criteria = null )
Deletes documents with the specified primary keys.
See find() for detailed explanation about $condition and $params.
Deletes documents with the specified primary keys.
See find() for detailed explanation about $condition and $params.
Parameters
- $pkValues
- Primary keys array
- $criteria
- query criteria.
Returns
boolean
Since
v1.0
Implementation of
|
public
boolean
|
#
deleteAll( array|Maslosoft\Mangan\Interfaces\CriteriaInterface $criteria = null )
Deletes documents with the specified primary keys.
Deletes documents with the specified primary keys.
Does not raise beforeDelete event and does not emit signals
See find() for detailed explanation about $condition and $params.
Parameters
- $criteria
- query criteria.
Returns
boolean
Since
v1.0
Implementation of
|
public
MongoCollection
|
#
getCollection( )
Get mongodb collection
Returns
MongoCollection PHP Driver MongoCollection instance
Implementation of
|