Skip to content
Snippets Groups Projects
EntryValues.php 958 B
Newer Older
Josh Pollock's avatar
Josh Pollock committed
<?php


namespace calderawp\CalderaFormsQuery\Delete;

class EntryValues extends DeleteQueryBuilder
{

	/**
	 * Delete field by entry ID
	 *
	 * @param int $entryId Entry ID
	 * @return $this
	 */
	public function deleteByEntryId($entryId)
	{
		$this
			->getDeleteQuery()
			->where()
Josh Pollock's avatar
Josh Pollock committed
			->equals('entry_id', (int)$entryId)
Josh Pollock's avatar
Josh Pollock committed
		;
		return $this;
	}

	/**
	 * Delete a collection of entry values that are for a a set of entries.
	 *
	 * @param array $entryIds
	 * @return $this
	 */
	public function deleteByEntryIds(array $entryIds)
	{
		return $this->in($entryIds,'entry_id');

	}

Josh Pollock's avatar
Josh Pollock committed
	/**
	 * Delete all field values with a value
	 *
	 * @param string $fieldSlug
	 * @param string $fieldValue
	 * @return $this
	 */
	public function deleteByFieldValue($fieldSlug, $fieldValue)
	{
		$this
			->getDeleteQuery()
			->where()
Josh Pollock's avatar
Josh Pollock committed
			->equals('value', $fieldValue)
Josh Pollock's avatar
Josh Pollock committed

		;

		$this
			->getDeleteQuery()
			->where()
Josh Pollock's avatar
Josh Pollock committed
			->equals('slug', $fieldSlug);
Josh Pollock's avatar
Josh Pollock committed
		return $this;
	}
Josh Pollock's avatar
Josh Pollock committed
}