1
votes

I need to store integer and string values in one field. What type should I use in mapping? When I use string, I get integer values as string in my mongo documents.

2

2 Answers

2
votes
0
votes

Use the string mapping. Then in your getter for the field if you need to return different types. Use something like this

public function getTransgenderField() {
    if (is_numeric($this->transgenderField)) {
        return (int) $this->transgenderField;
    }
    return $this->transgenderField;
}