Search code examples
symfonypropel

Is there way to change column values of selected rows through Propel?


Rows are selected like that:

$book->getBookGenreToBooks()->???()

I want to change the column «checked» of all selected rows.


Solution

  • Your given solution in your answer is very inefficient since it creates for each update a new query. A better way is to do all changes in one query:

    BookGenreQuery::create()
        ->filterByBookId($book->getId())
        ->update(array('Checked' => 1));
    

    I don't know how exactly your relations and fields are named by you should get the idea behind it.