Skip to main content

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?

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;

Related Posts:

Balazs Nadasdi

Developer, Project Manager, Blogger, Dad... or sometihng like these