public function up()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
// Организации
$this->createTable('{{%company}}', [
'id' => $this->primaryKey(),
'name' => $this->string(),
'code' => $this->string(),
'city' => $this->string(),
'address' => $this->string(),
'schedule' => $this->string(),
'link' => $this->string(),
], $tableOptions);
// Телефоны
$this->createTable('{{%phone}}', [
'id' => $this->primaryKey(),
'company_id' => $this->integer(),
'number' => $this->string(),
], $tableOptions);
$this->createIndex('idx-phone-company_id', '{{%phone}}', 'company_id');
$this->addForeignKey("fk-phone-company", "{{%phone}}", "company_id", "{{%company}}", "id", 'SET NULL', 'RESTRICT');
}
'columns' => [
[
'attribute' => 'title',
'format' => 'html',
'value' => function($model, $key, $index) {
if(($index % 2) == 0){
return "я четная строка";
}else{
return "я сука не сильно четная";
}
}
],
yii\web\UploadedFile::getInstance()
yii\web\UploadedFile::getInstances()
<?= $form->field($model, 'myAttribute[]')->fileInput();?>
<?= $form->field($model, 'myAttribute[]')->fileInput();?>
<?= $form->field($model, 'myAttribute[]')->fileInput();?>
<?= $form->field($model, 'myAttribute[]')->fileInput();?>
<?= $form->field($model, 'myAttribute[]')->fileInput();?>
<?= $form->field($model, 'myAttribute[]')->fileInput();?>
class Registry {
private static $storage = array();
public static function set($key,$value){
self::$storage[$key] =$value;
}
public static function get($key){
if(isset(self::$storage[$key]))
return self::$storage[$key];
else return false;
}
public static function getInstance(){
return self::$storage;
}
}
For the above implementation to work with MySQL database, please declare the columns(created_at, updated_at) as int(11) for being UNIX timestamp.