published on in PHP
tags: mongodb mysql php database

MySQL + MongoDB + PHP

We used MySQL with PHP… In the past months we try to migrate MySQL tables to MongoDB. And yes it was not a simple method (but we did it).

Now I’ll tell you a simple source of bugs because i have too much fun with this. We have a users table with some fields for example member_type (int). The types already migrated to MongoDB. We fetch the user and we make a query with member_type value but it doesn’t work for us. Why?

MySQL + MongoDB + PHP

Yes. When i call var_dump then i get a string but in MongoDB we need an integer. If you don’t use any ORM then if you fetch any data from MySQL what is an integer then you need a type conversion: (int)$row->member_type;