On 12/22/2011 11:20 AM, Dmitri Snytkine wrote: > Not sure what you mean by json wrapped. > In mongo you do $coll->find(array('age' => $age); > > if $age is a string '21' your will not get any erros but neither will you > get any results.
It is json underneath, but in your find() example, obviously the right approach here is to do: $coll->find(array('age' => (int)$age); How is that hard? You wouldn't use a strong int type in the find() function prototype here at all since by definition the find() function needs to take all sorts of types. This is why I mentioned access functions related to Mongo. You might write something like: function age_lookup($age) { return $coll->find(array('age' => (int)$age); } but again here, doing a strong type check on the parameter isn't making your life easier. It simply pushes the responsibility to the caller and introduces a tricky unrecoverable error that will drive you crazy unless you have 100% regression test coverage (which is kind of impossible since the number of inputs is infinite) or great static analysis tools. PHP is not a compiled language, so you end up not catching these until runtime which is obviously sub-optimal. -Rasmus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php