I tried this:
$result = (array)DB::selectOne('SELECT * FROM campaign WHERE id = ? FOR UPDATE', [$data['campaign_id']]);
$campaign = new Campaign($result);
$campaign->counter += 1;
$campaign->save();
But I get this error on save Integrity constraint violation: 1062 Duplicate entry '1' for key
, because it thinks I'm trying to work with a new campaign, not an existing one.
Edit: Why doesn't it know it exists, considering I have the primary key set.