A
A
Alexey Nikolaev2015-10-14 21:06:54
Yii
Alexey Nikolaev, 2015-10-14 21:06:54

Why can it be that ActiveRecord saves empty values ​​in the database?

Good night all.
Faced a strange effect - the save method of an AR instance returns true, zero errors, creates a new row in the database, but all the fields in it are empty (even the one marked as CURRENT_TIMESTAMP by default). From the point of view of the code, everything simply should not work.

$arBanners = new Banners();
$arBanners->setAttributes([
    'type'     => 'sometype',
    'image'  => 'someurl'
]);
$arBanners->save(false); // даже если валидацию не отключить, эффект будет тем же самым

In the model itself, everything is more than standard. I'll never know where to dig. There is a table, there is a connection, there are also fields in the table , the query through DBO works as it should. What could be the problem?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D', 2015-10-14
@Heian

Doesn't Yii have protection against mass assignment? Maybe this is the issue? It is worth looking in the model what fields are allowed there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question