Yoast\WP\Lib

ORM::update_many()publicYoast 1.0

Updates many records in the database.

Метод класса: ORM{}

Хуков нет.

Возвращает

int|true|false. The number of rows changed if the query was succesful. False otherwise.

Использование

$ORM = new ORM();
$ORM->update_many();

Код ORM::update_many() Yoast 22.4

public function update_many() {
	// Remove any expression fields as they are already baked into the query.
	$values = \array_values( \array_diff_key( $this->dirty_fields, $this->expr_fields ) );

	// UPDATE.
	// If there are no dirty values, do nothing.
	if ( empty( $values ) && empty( $this->expr_fields ) ) {
		return true;
	}

	$query = $this->join_if_not_empty( ' ', [ $this->build_update(), $this->build_where() ] );

	$success            = self::execute( $query, \array_merge( $values, $this->values ) );
	$this->dirty_fields = [];
	$this->expr_fields  = [];

	return $success;
}