here's the code itself
$basePath='page/2016/10/'; $field='id_page'; $id=1; $name='podborka_vecher_01.jpg,%, podborka_vecher_17.jpg' public function baseSave($basePath,$field,$id,$name){ $transliterator= new Translit(); $bp = array(); if(preg_match('/,%,/',$name)){ $mathes=explode(',%,',$name); foreach ($mathes as $math){ $bp[] = $basePath; $names=$transliterator->traranslitImg($math); $theImage= Image::findOne(['path'=>$basePath, 'name'=>$name ]); if(!isset($theImage)){ $this->path=$basePath; $this->$field=$id; $this->name=$names; $this->insert(); } } }else{ $names=$transliterator->traranslitImg($name); $theImage= Image::findOne(['path'=>$basePath, 'name'=>$name ]); if(!isset($theImage)) { $this->path = $basePath; $this->$field = $id; $this->name = $names; $this->save(); } } } I get the following error
SQLSTATE[HY000]: General error: 1364 Field 'path' doesn't have a default value The SQL being executed was: INSERT INTO `abh_image` (`name`) VALUES ('-podborka_vecher_17.jpg') I do not understand where the work has gone with this
$this->path=$basePath; $this->$field=$id; and why only $this->name=$names;