php - Selecting a collection with a dot in its name -
i select collection using following method... assuming collection name "fantastic" in database called "somedb"
$conn = new mongo(); $fantastic_coll = $conn->somedb->fantastic;
this has worked famously me long time. number of collections using has grown lot , i'm trying use dots in collection names organise them little more logically.
eg.
- store.items
- store.categories
- store.coupons
- events
- events.categories
this seems work fine in mongodb shell, not in php?
if try....
$conn = new mongo(); $store_coupons_coll = $conn->somedb->store.coupons;
and try save documents collection doesn't me.
if instead use...
$conn = new mongo(); $store_coupons_coll = $conn->somedb->selectcollection('store.coupons');
everything works expected. right way it?
- if hope helps having same trouble.
- if not there short way write collection name?
- is using dots in collection name organisation wrong begin with?
the preferred way of doing with:
$collection = $conn->somedb->selectcollection( 'store.coupons' );
or if want:
$collection = $conn->selectcollection( 'somedb', 'store.coupons' );
Comments
Post a Comment