如何获取模型属性的数据库列属性?与数据类型,默认值,大小等相似。
答案 0 :(得分:0)
您可以使用$customer_model->getTableSchema()
或Customer::getTableSchema()
为您提供以下内容:
yii\db\TableSchema#1 ( [schemaName] => null [name] => 'customers' [fullName] => 'customers' [primaryKey] => [ 0 => 'customerID' ] [sequenceName] => '' [foreignKeys] => [ 0 => [ 0 => 'orders' 'ord_customerID' => 'customerID' ] ] [columns] => [ 'customerID' => yii\db\ColumnSchema#2 ( [name] => 'customerID' [allowNull] => false [type] => 'integer' [phpType] => 'integer' [dbType] => 'int(10) unsigned' [defaultValue] => null [enumValues] => null [size] => 10 [precision] => 10 [scale] => null [isPrimaryKey] => true [autoIncrement] => true [unsigned] => true [comment] => '' ) ...