AngelGabriel Posted September 2, 2013 Share Posted September 2, 2013 Hi. I need check existing doc in collection. public function insertMuvik( $mu ) { if( is_array( $mu ) ) { foreach( $mu AS $k => $v ) { if( !in_array( $k, self::$allow ) ) { unset( $mu[$k] ); } } $docOnTtitle = Base::$db->objects->find( array( 'title' => $mu['title'] ) )->count(); $docOnYoutubeID = Base::$db->objects->find( array( 'youtube_id' => $mu['youtube_id'] ) )->count(); if ( !$docOnTtitle && !$docOnYoutubeID ) { $res = Base::$db->objects->insert( $mu ); if( $res['err'] == NULL ) { return $mu['_id']; } } else { return false; } } return false; } this method, do not work. maybe need try $exist. Pleas help. Link to comment https://forums.phpfreaks.com/topic/281784-how-check-exist-value-in-mongodb-php-driver/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.