[英]Yii2: How do I get the database properties of model attributes?
如何獲得模型屬性的數據庫列屬性? 像數據類型,默認值,大小等。
您可以使用$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] => '' ) ...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.