We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

zero-length keys are not allowed, did you use $ with double quotes?

Hi - I'm trying to store multiple data models with protected properties into a \Phalcon\Mvc\Collection and I am ending up with the following exception:

object(MongoException)[64] protected 'message' => string 'zero-length keys are not allowed, did you use $ with double quotes?' (length=67) private 'string' (Exception) => string '' (length=0) protected 'code' => int 1 protected 'file' => string '...' (length=74) protected 'line' => int 73 private 'trace' (Exception) => array (size=8) 0 => array (size=4) 'function' => string 'save' (length=4) 'class' => string 'MongoCollection' (length=15) 'type' => string '->' (length=2) 'args' => array (size=2) ...

I've narrowed the cause down to being the protected properties by removing them and the saving successfully afterward. Unfortunately, I do not want the protected properties to be stored in the collection.

Please let me know if this is a bug or if there is a way around this.

Thanks! Don



2.4k

You can close this discussion - It looks like the pecl Mongo client doesn't support this.

Thanks