Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine2 update only using objects

Is there any way to make update with criteria in Doctrine2 without using DQL and Native SQL? I mean only working with objects.

For example something like this:

$data = new Entities\Articles();
$data->setStatus("published");

/*
  Add some criteria for update here 
*/

$em->persist($data);
$em->flush();

What I want to do: Update multiple records without loading them from database.

like image 755
Juris Vaiders Avatar asked Nov 29 '25 02:11

Juris Vaiders


1 Answers

No, Doctrine ORM does not currently support using the criteria API for updates. Criteria API is currently only available to fetch data, and still at a very early state.

If you can help us improve it, that would be awesome :)

The only currently available ways are through DQL and NativeSQL

like image 91
Ocramius Avatar answered Nov 30 '25 16:11

Ocramius



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!