Try using curly braces instead of parentheses:
$this->mongo->{$this->db}->$collection_name->insert($document_name);
Or by assigning to the $this->dblocal var and using this instead:
$db_name = $this->db;
$this->mongo->$db_name->$collection_name->insert($document_name);
source
share