0

I have a custom data table PA in the Craft database. I create a craft\db\ActiveRecord model and I want load() and save() data to it. The result will be custom GridView table with CRUD in front end combined with cms pages.

When I call $model->save() it throws Exception:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'dateUpdated' in 'field list'

The SQL being executed was: UPDATE `PA` SET `background`='#ffff00', `dateUpdated`='2018-10-03 11:50:26' 
WHERE `idPA`=17
Error Info: Array
(
[0] => 42S22
[1] => 1054
[2] => Unknown column 'dateUpdated' in 'field list'
)

Caused by: PDOException
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'dateUpdated' in 'field list'

What is the difference between craft\db\ActiveRecord and yii\db\ActiveRecord? Is there any recommendation how to use it?

Thanks.

3

The only difference between Craft and Yii active records are the columns dateCreated, dateUpdated and uid if you have these columns you should extend Crafts ActiveRecord since it's save function adds compability to those columns otherwise just use Yii2 ActiveRecord

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.