Jump to content

How check exist value in mongodb. PHP driver.


AngelGabriel

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.