Welcome Guest, Not a member yet? Register   Sign In
$model update function always returns 1 even not data updated
#1
Shocked 

Hello,
As example mentioned in the documentation:
In Documentation:
$userModel
    ->whereIn('id', [1,2,3])
    ->set(['active' => 1])
    ->update();


Changes:

$result = $this->modelPsVotes
                    ->where('fk_id'$fkId1)
                    ->where('fk_id'$fkId2)
                    ->set(['name' => 'Test'])
                    ->update();

but if I save the value in the variable $result and print it always 1, even the data is not updated. 

Any suggestion?
Reply
#2

1 = true
true = Query was executed without errors
use the affectedRows() method to control changes
Reply
#3

Thanks for the answer, but affectedRows() function is not in the model.
Reply
#4

Use $this->modelPsVotes->db->affectedRows()

Error with $this->modelPsVotes->affectedRows() - bug
Reply
#5

(09-25-2021, 11:37 PM)iRedds Wrote: Use $this->modelPsVotes->db->affectedRows()

Error with $this->modelPsVotes->affectedRows() - bug

Thank you so much, that is very helpful.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB