Did some testing
Made a simple Model:
class Tester extends \Phalcon\Mvc\MongoCollection {
public static function findA() {
return self::findFirst();
}
}
And two CLI tests:
public function test1Action(array $params = null) {
$t = new self();
$t->test = 'here is a string';
$t->save();
}
public function test2Action(array $params = null) {
$t = self::findA();
echo 'test: ', $t->test, PHP_EOL, PHP_EOL;
$t->test = 'another string';
$t->save();
}
After running test1
, I get this in Mongo:
{
"_id" : ObjectId("58f5ee18962d741fd126d472"),
"_dependencyInjector" : {
},
"_modelsManager" : {
},
"_source" : "tester",
"_operationMade" : 1,
"_dirtyState" : 1,
"_connection" : {
},
"_errorMessages" : [ ],
"_skipped" : false,
"test" : "here is a string"
}
All good, but where did these underscore-prefixed properties come from??? Never seen before.
When I run test2
, I get this:
test: here is a string
PHP Fatal error: Uncaught Phalcon\Mvc\Collection\Exception: A dependency injector container is required to obtain the services related to the ODM in /var/www/proj/shared/utils/incubator/Library/Phalcon/Mvc/MongoCollection.php:76
Stack trace:
#0 /var/www/proj/cli/app/tasks/TestTask.php(3168): Phalcon\Mvc\MongoCollection->save()
#1 [internal function]: TestTask->test2Action(Array)
#2 [internal function]: Phalcon\Cli\Dispatcher->callActionMethod(Object(TestTask), 'test2Action', Array)
#3 [internal function]: Phalcon\Dispatcher->_dispatch()
#4 [internal function]: Phalcon\Dispatcher->dispatch()
#5 /var/www/proj/cli/app/cli.php(42): Phalcon\Cli\Console->handle(Array)
#6 {main} thrown in /var/www/proj/shared/utils/incubator/Library/Phalcon/Mvc/MongoCollection.php on line