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

13 lines
292 B
PHP
Raw Normal View History

2024-03-28 09:51:45 +03:00
<?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]);
}
}