CDbCommand 无法执行 SQL 语句: SQLSTATE[HY000]: General error: 1366 Incorrect string value
CDbCommand 无法执行 SQL 语句: SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xDB~***\x9A' for column 'message' at row 1. The SQL statement executed was: INSERT INTO `sys_log` (`user_id`, `user_name`, `category`, `log_type`, `level`, `message`, `log_ip`, `log_time`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7) YIi报错待解决
学习Yii2微服务框架 实现一些基本功能 及案例 'id' => 'micro-app', // the basePath of the application will be the `micro-app` directory 'basePath' => __DIR__, // this is where the application will find all controllers 'controllerNamespace' => 'micro\controllers', // set an alias to enable autoloading of classes from the 'micro' namespace 'aliases' => [ '@micro' => __DIR__, ], 'language' => 'zh-CN', 'components' => [ //获取JSON数据 'request' => [ 'parsers' => [ 'application/json' => 'yii\web\JsonParser', ] ], //配置自定义响应 'response' => [ 'class' => 'yii\web\Response', 'on beforeSend' => function ($event) { $response = $event->sender; $code = $response->getStatusCode(); $msg = $response->statusText; if ($code == 404) { !empty($response->data['message']) && $msg = $response->data['message']; } //设置固定返回数据参数 $data = [ 'code' => $code, 'msg' => $msg, 'data' => $response->data ]; $code == 200 && $data['data'] = $response->data; $response->data = $data; $response->format = yii\web\Response::FORMAT_JSON; }, ], //会员 'user' => [ 'identityClass' => 'common\models\User', 'enableAutoLogin' => true, 'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true], ], //URL美化 'urlManager' => [ 'enablePrettyUrl' => true, 'enableStrictParsing' => true, 'showScriptName' => false, 'rules' => [ '' => 'site/index', ['class' => 'yii\rest\UrlRule', 'controller' => 'post','pluralize'=>false], ], ], //连接MYSQL数据库 'db' => [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=localhost;dbname=micro', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8', ], 'cookieValidationKey' => 'O1d232trde1xww-M97_7QvwPo-5QGdkLMp#@#@', ], 以下为DEMOmicro-app.zip
frontend/web/index.php<?phpdefined('YII_DEBUG') or define('YII_DEBUG', true); //false 换成true
1.打开到项目的目录，举例如我的项目位于D:www下命令行：cmd-->cd D:\www\ D: D:\www> 2.安装Yii2输入以下命令进行安装yii2 高级模板composer create-project --prefer-dist yiisoft/yii2-app-advanced kmoa如果出现Loading composer repositories with package information 卡住不动这更改下composer的源镜像为国内《composer安装出现Loading composer repositories with package information卡住不动》CTRL+C中断当前，输入yes。重来3.设置国内镜像 composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ 4.重新安装 composer create-project --prefer-dist yiisoft/yii2-app-advanced kmoa 5.安装成功但加载库失败 见图（因为墙的缘故）6.打开kmoa目录 增加阿里云镜像 "repositories": [ { "type": "composer", "url": "https://mirrors.aliyun.com/composer/" }, { "type": "composer", "url": "https://asset-packagist.org" } ]7.执行composer install安装中...8.安装成功9.初始化