Currently i run a mongo query that looks similar to the following:
$query = array(
\'user_id\' => $this->getUserId(),
\'name\' => $this->g
Based off your problem, I would suggest re-trying "'created' => $this->getCreated() to the $query" provided your model has a created property defined, and your getter method is working, then this should use the current date on an insert, and the pre-set property value on update.
This is because of your $query
value. It is a common beginner mistake.
Placing a whole query document into update like so:
$query = array(
'user_id' => $this->getUserId(),
'name' => $this->getName()
);
Without any operators will actually REPLACE the original document with this one.
Instead to $set
those fields to a new value you should use $set
:
$query = array('$set' => array(
'user_id' => $this->getUserId(),
'name' => $this->getName() )
);
This should give you the effect you desire.