Is this line legal PHP?
$this->mongo->($this->db)->$collection_name->insert($document_name);
if $this->db is a constant with the db name to use.
Thank you
Try using curly braces instead of parentheses:
$this->mongo->{$this->db}->$collection_name->insert($document_name);
Or assigning $this->db
to a local var and using that instead:
$db_name = $this->db;
$this->mongo->$db_name->$collection_name->insert($document_name);
No, strings (and thus your constant) should be wrapped in brackets, like this:
$this->mongo->{$this->db}->$collection_name->insert($document_name);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With