portal.mkgtu.ru/common/models/traits/ColumnExistsTrait.php

13 lines
292 B
PHP
Executable File

<?php
namespace common\models\traits;
trait ColumnExistsTrait
{
private function checkIfColumnExists($columnName)
{
$class = get_called_class();
$table = \Yii::$app->db->getTableSchema($class::tableName());
return isset($table->columns[$columnName]);
}
}