In Yii2, how do you ensure that the field type in the interface response is consistent with that in MySQL?
1. Check the existing interface response, “Status”: “1”, , the type of the status field in the table is tinyint . as shown in Figure 1
2. Configure Components[‘db’]Medium adjustment, add attributes[PDO::ATTR_STRINGIFY_FETCHES]=> False and Attributes[PDO::ATTR_EMULATE_PREPARES]=> false
return [
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=apply_server_v6',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8mb4',
'attributes' => [
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_EMULATE_PREPARES => false,
],
],
],
];
3. Check the response of the interface again, the type of the field has been consistent with the one of MySQL. in line with expectations. as shown in Figure 2

