我正在对模型使用以下查询
$criteria = new CDbCriteria;
$criteria->condition='brand_id=3';
$model=Models::model()->find($criteria);
它给出了表结构和关系表结构的结果,如下所示
Models Object ( [_md:CActiveRecord:private] => CActiveRecordMetaData Object ( [tableSchema] => CMysqlTableSchema Object ( [schemaName] => [name] => models [rawName] => `models` [primaryKey] => model_id [sequenceName] => [foreignKeys] => Array ( [brand_id] => Array ( [0]
=> brands [1] => brand_id ) ) [columns] => Array ( [model_id] => CMysqlColumnSchema Object ( [name] => model_id [rawName] => `model_id` [allowNull] => [dbType] => int(11) [type] => integer [defaultValue] => [size] => 11 [precision] => 11 [scale] => [isPrimaryKey] => 1 [isForeignKey] => [autoIncrement] => 1 [_e:CComponent:private] => [_m:CComponent:private] => ) [model_name] => CMysqlColumnSchema Object ( [name] => model_name [rawName] => `model_name` [allowNull] => [dbType] => varchar(255) [type] => string [defaultValue] => [size] => 255 [precision] => 255 [scale] => [isPrimaryKey] => [isForeignKey] => [autoIncrement] => [_e:CComponent:private] => [_m:CComponent:private]
=> ) [brand_id] => CMysqlColumnSchema Object ( [name] => brand_id [rawName] => `brand_id` [allowNull] => [dbType] => int(11) [type] => integer [defaultValue] => [size] => 11 [precision] => 11 [scale] => [isPrimaryKey] => [isForeignKey] => 1 [autoIncrement] => [_e:CComponent:private] => [_m:CComponent:private] => ) ) [_e:CComponent:private] => [_m:CComponent:private] => ) [columns] => Array ( [model_id] => CMysqlColumnSchema Object ( [name] => model_id [rawName] => `model_id` [allowNull] => [dbType] => int(11) [type] => integer [defaultValue] => [size] => 11 [precision] => 11 [scale] => [isPrimaryKey] => 1 [isForeignKey] => [autoIncrement] => 1 [_e:CComponent:private] => [_m:CComponent:private] => ) [model_name]
=> CMysqlColumnSchema Object ( [name] => model_name [rawName] => `model_name` [allowNull] => [dbType] => varchar(255) [type] => string [defaultValue] => [size] => 255 [precision] => 255 [scale] => [isPrimaryKey] => [isForeignKey] => [autoIncrement] => [_e:CComponent:private] => [_m:CComponent:private] => ) [brand_id] => CMysqlColumnSchema Object ( [name] => brand_id [rawName] => `brand_id` [allowNull] => [dbType] => int(11) [type] => integer [defaultValue] => [size] => 11 [precision] => 11 [scale] => [isPrimaryKey] => [isForeignKey] => 1 [autoIncrement] => [_e:CComponent:private] => [_m:CComponent:private] => ) ) [relations] => Array ( [brand] => CBelongsToRelation Object ( [joinType] => LEFT OUTER JOIN [on] => [alias] => [with] => Array ( ) [together] => [scopes] => [name] => brand [className] => Brands [foreignKey] => brand_id [select] => * [condition] => [params] => Array ( ) [group] => [join] => [having] => [order] => [_e:CComponent:private] => [_m:CComponent:private] => ) ) [attributeDefaults] => Array ( ) [_model:CActiveRecordMetaData:private] => Models Object ( [_md:CActiveRecord:private] => CActiveRecordMetaData Object
*RECURSION* [_new:CActiveRecord:private] => [_attributes:CActiveRecord:private] => Array ( ) [_related:CActiveRecord:private] => Array ( ) [_c:CActiveRecord:private] => [_pk:CActiveRecord:private] => [_alias:CActiveRecord:private] => t [_errors:CModel:private] => Array ( ) [_validators:CModel:private] => [_scenario:CModel:private] => [_e:CComponent:private] => [_m:CComponent:private] => ) ) [_new:CActiveRecord:private] => [_attributes:CActiveRecord:private] => Array ( [model_id] => 3 [model_name] => NANO [brand_id] => 3 ) [_related:CActiveRecord:private] => Array ( ) [_c:CActiveRecord:private] => [_pk:CActiveRecord:private] => 3 [_alias:CActiveRecord:private] => t [_errors:CModel:private] => Array ( ) [_validators:CModel:private] => [_scenario:CModel:private] => update [_e:CComponent:private] => [_m:CComponent:private] => )
如何仅在 yii 查询中获取表数据