src/Relations/ManyToMany.php
protected function persist_removed( $removed ) {

		$cached = wp_cache_get( $this->parent->get_pk(), $this->get_cache_group() ) ?: array();

		global $wpdb;

		$where = new Where( 1, false, 1 );

		foreach ( $removed as $model ) {

			$i = array_search( $this->saver->get_pk( $model ), $cached );

			if ( $i !== false ) {
				unset( $cached[ $i ] );
			}

			$remove_where = new Where( $this->other_column, true, esc_sql( $this->parent->get_pk() ) );
			$remove_where->qAnd(
				new Where( $this->primary_column, true, esc_sql( $this->saver->get_pk( $model ) ) )
			);

			$where->qOr( $remove_where );
		}

		wp_cache_set( $this->parent->get_pk(), $cached, $this->get_cache_group() );

		$wpdb->query( "DELETE FROM `{$this->association->get_table_name( $wpdb )}` $where" );
	}
protected function persist_removed( $removed ) {

		$cached = wp_cache_get( $this->parent->get_pk(), $this->get_cache_group() ) ?: array();

		global $wpdb;

		$where = new Where( 1, false, 1 );

		foreach ( $removed as $model ) {

			$i = array_search( $this->saver->get_pk( $model ), $cached );

			if ( $i !== false ) {
				unset( $cached[ $i ] );
			}

			$remove_where = new Where( $this->other_column, true, esc_sql( $this->parent->get_pk() ) );
			$remove_where->qAnd(
				new Where( $this->primary_column, true, esc_sql( $this->saver->get_pk( $model ) ) )
			);

			$where->qOr( $remove_where );
		}

		wp_cache_set( $this->parent->get_pk(), $cached, $this->get_cache_group() );

		$wpdb->query( "DELETE FROM `{$this->association->get_table_name( $wpdb )}` $where" );
	}
Persist the removed models.

@since 2.0

@param DoctrineCollection $removed