Unable to use model in migration in Yii 1.x

Using migration to insert or modify table structure is not a problem for me. But I have problems changing the data inside the table using the model. My idea is to do something like this:

public function up()
{
    $models = MyModel::model()->findAll();
    foreach ($models as $variable) {
        $variable->property = str_replace('.', ',', $variable->property);
        $variable->save();
    } 
}

It seems that I cannot import the model because I am getting the following error:

*** applying m111010_084827_convert_point_2_comma
PHP Error[2]: include(MyModel.php): failed to open stream: No such file or directory

If I try to import the model earlier:

$modelClass = Yii::import('application.models.*');

then the error:

*** applying m111010_084827_convert_point_2_comma
exception 'CDbException' with message 'The table "{{mymodel}}" for active record class "MyModel" cannot be found in the database.' in C:\...\yii\framework\db\ar\CActiveRecord.php:2276

Where is the problem? What am I doing wrong? How to import a model during the migration in the right direction? Or maybe I should replace the rows with SQL commands?

+5
source share
1 answer

SQL. SELECT REPLACE. . http://www.1keydata.com/sql/sql-replace.html

, , , php. :

   Yii::import('application.models.*');
   Yii::import('application.models.base.*');

, config/console.php, .

+3

All Articles