插入数据是出现General error [ 求助交流 ]
建表语句:
CREATE TABLE article
(
id
int(11) NOT NULL AUTO_INCREMENT,
sort_id
int(11) NOT NULL DEFAULT '0',
top
int(11) NOT NULL DEFAULT '0' COMMENT '推荐',
title
char(255) CHARACTER SET latin1 NOT NULL,
time
int(11) NOT NULL DEFAULT '0',
content
text CHARACTER SET latin1 NOT NULL,
tag
varchar(500) NOT NULL DEFAULT '',
PRIMARY KEY (id
)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4;
错误信息:
Exception (Database Exception) 'yii\db\Exception' with message 'SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xE5\x89\x8D\xE7\xAB\xAF...' for column 'content' at row 1
The SQL being executed was: INSERT INTO `article` (`sort_id`, `title`, `time`, `top`, `content`, `tag`) VALUES (1, 'tttt', 1499937403, 3, '<p>前端 – React 路由</p><p>React Router 课程介绍</p><p>安装 React Router</p><p> jspm install react-router@1.0.0.rcl</p><p> ————————</p><p> import { Router, Route, Link } from ‘react-router’;</p><p> ————————</p><p>准备 React 组件</p><p> —————————</p><p> ‘use strict’;</p><p> import ‘semantic-ui/semantic.min.css!’;</p><p> import React from ‘react’;</p><p> import ReactDOM from ‘react-dom’;</p><p> import { Router, Route, Link } from ‘react-router’;</p><p> class App extends React.Component {</p><p> render(){</p><p> return(</p><p> <div className=”ui secondary pointing menu”></p><p> { /* links*/}</p><p> </div></p><p> {this.props.children}</p><p> );</p><p> }</p><p> }</p><p> class TV extends React.Component{</p><p> render(){</p><p> return(</p><p> <div></p><p> <div className=”ui info message”></p><p> TV LIST</p><p> </div></p><p> {this.props.children}</p><p> </div></p><p> );</p><p> }</p><p> }</p><p> class Show extends React.Component{</p><p> render(){</p><p> return(</p><p> <h3>节目</h3></p><p> );</p><p> }</p><p> }</p><p> —————————</p><p>定义路由</p><p> ————————–</p><p> ………..</p><p> class App extends React.Component {</p><p> render(){</p><p> return(</p><p> <div className=”ui secondary pointing menu”></p><p> <Link to=”/” className=”item”>index</Link></p><p> <Link to=”/tv” className=”item”>TV</Link></p><p> </div></p><p> {this.props.children}</p><p> );</p><p> }</p><p> }</p><p> ………….</p><p> ReactDOM.render((</p><p> <Router></p><p> <Route path=”/” component={App}></p><p> <Route path=”tv” component={TV}></p><p> <Route path=”shows/:id” component={Show}/></p><p> </Route></p><p> </Route></p><p> </Router></p><p> ), document.getElementById(‘app’));</p><p> ————————–</p><p>得到地址里的参数</p><p> ————————</p><p> ………….</p><p> class Show extends React.Component{</p><p> constructor(props){</p><p> super(props);</p><p> console.log(this.props.params);</p><p> }</p><p> render(){</p><p> return(</p><p> <h3>节目 {this.props.params.id}</h3></p><p> );</p><p> }</p><p> }</p><p> …………..</p><p> ————————</p><p>索引 – IndexRoute</p><p> ——————–</p><p> ‘use strict’;</p><p> import ‘semantic-ui/semantic.min.css!’;</p><p> import React from ‘react’;</p><p> import ReactDOM from ‘react-dom’;</p><p> import { Router, Route, Link, IndexRoute } from ‘react-router’;</p><p> class App extends React.Component {</p><p> render(){</p><p> return(</p><p> <div className=”ui secondary pointing menu”></p><p> <Link to=”/” className=”item”>index</Link></p><p> <Link to=”/tv” className=”item”>TV</Link></p><p> </div></p><p> {this.props.children}</p><p> );</p><p> }</p><p> }</p><p> class TV extends React.Component{</p><p> render(){</p><p> return(</p><p> <div></p><p> {this.props.children}</p><p> </div></p><p> );</p><p> }</p><p> }</p><p> class Show extends React.Component{</p><p> constructor(props){</p><p> super(props);</p><p> console.log(this.props.params);</p><p> }</p><p> render(){</p><p> return(</p><p> <h3>节目 {this.props.params.id}</h3></p><p> );</p><p> }</p><p> }</p><p> class Home extends React.Component{</p><p> render(){</p><p> return(</p><p> <div className=”ui info message”>Index Content</div></p><p> );</p><p> }</p><p> }</p><p> class ShowIndex extends React.Component{</p><p> render(){</p><p> <div className=”ui info message”>TV LIST</div></p><p> };</p><p> }</p><p> ReactDOM.render((</p><p> <Router></p><p> <Route path=”/” component={App}></p><p> <IndexRoute component={Home}/></p><p> <</p><p> <Route path=”tv” component={TV}></p><p> <IndexRoute component={ShowIndex}/></p><p> <Route path=”shows/:id” component={Show}/></p><p> </Route></p><p> </Route></p><p> </Router></p><p> ), document.getElementById(‘app’));</p><p> ——————–</p><p> http://localhost/</p><p> http://localhost/#/tv</p><p> http://localhost/#/tv/shows/1</p><p>路由里的绝对路径与重定向</p><p> ———————–</p><p> import { Router, Route, Link, IndexRoute, Redirect } from ‘react-router’;</p><p> ………………</p><p> ReactDOM.render((</p><p> <Router></p><p> <Route path=”/” component={App}></p><p> <IndexRoute component={Home}/></p><p> <</p><p> <Route path=”tv” component={TV}></p><p> <IndexRoute component={ShowIndex}/></p><p> <Route path=”/shows/:id” component={Show}/></p><p> </Route></p><p> <Redirect from=”show/:id” to=”/show/:id”/></p><p> </Route></p><p> </Router></p><p> ), document.getElementById(‘app’));</p><p> ———————–</p><p> http://localhost/#/shows/1</p><p> http://localhost/#/tv/shows/1</p><p>进入与离开 – onEnter, onLeave</p><p> ———————–</p><p> ………………</p><p> function handleEnter(){</p><p> console.log(‘Enter’);</p><p> }</p><p> function handleLeave(){</p><p> console.log(‘Leave’);</p><p> }</p><p> ReactDOM.render((</p><p> <Router></p><p> <Route path=”/” component={App}></p><p> <IndexRoute component={Home}/></p><p> <</p><p> <Route path=”tv” component={TV}></p><p> <IndexRoute component={ShowIndex}/></p><p> <Route path=”/shows/:id” component={Show}</p><p> onEnter={handleEnter}</p><p> onLeave={handleLeave}/></p><p> </Route></p><p> <Redirect from=”show/:id” to=”/show/:id”/></p><p> </Route></p><p> </Router></p><p> ), document.getElementById(‘app’));</p><p> ———————–</p><p>查询符 – query</p><p> ———————-</p><p> …………….</p><p> class TV extends React.Component{</p><p> constructor(props){</p><p> super(props);</p><p> let {query} = this.props.location;</p><p> console.log(this.props);</p><p> console.log(query);</p><p> }</p><p> render(){</p><p> return(</p><p> <div></p><p> {this.props.children}</p><p> </div></p><p> );</p><p> }</p><p> }</p><p> ……………</p><p> class App extends React.Component {</p><p> render(){</p><p> return(</p><p> <div className=”ui secondary pointing menu”></p><p> <Link to=”/” className=”item”>index</Link></p><p> <Link to=”/tv” className=”item” query={{orderBy: ‘date’}}>TV</Link></p><p> </div></p><p> {this.props.children}</p><p> );</p><p> }</p><p> }</p><p> ……………</p><p> ———————-</p><p>组件的生命周期与路由</p><p> ————————</p><p> class App extends React.Component {</p><p> componentDidMount(){</p><p> console.log(‘App did mount’);</p><p> }</p><p> componentWillReceiveProps(){</p><p> console.log(‘App will receive props’);</p><p> }</p><p> componentDidUpdate(){</p><p> console.log(‘App did update’);</p><p> }</p><p> …………..</p><p> }</p><p> class Home extends React.Component{</p><p> componentDidMount(){</p><p> console.log(‘Home did mount’);</p><p> }</p><p> componentWillUnmount(){</p><p> console.log(‘Home will unmount’);</p><p> }</p><p> ………..</p><p> }</p><p> class TV extends React.Component{</p><p> ………..</p><p> compontDidMount(){</p><p> console.log(‘TV did mount’);</p><p> }</p><p> ………..</p><p> }</p><p> ————————</p><p> Home did mount</p><p> App did mount</p><p> App will receive props</p><p> Home will unmount</p><p> Object…..</p><p> TV div mount</p><p> App did update</p><p><br/></p>', '')'
in E:\FrameWork\yii2\advanced\vendor\yiisoft\yii2\db\Schema.php:636
Stack trace:
#0 E:\FrameWork\yii2\advanced\vendor\yiisoft\yii2\db\Command.php(856): yii\db\Schema->convertException(Object(PDOException), 'INSERT INTO `ar...')
#1 E:\FrameWork\yii2\advanced\vendor\yiisoft\yii2\db\Schema.php(454): yii\db\Command->execute()
#2 E:\FrameWork\yii2\advanced\vendor\yiisoft\yii2\db\ActiveRecord.php(494): yii\db\Schema->insert('article', Array)
#3 E:\FrameWork\yii2\advanced\vendor\yiisoft\yii2\db\ActiveRecord.php(461): yii\db\ActiveRecord->insertInternal(NULL)
#4 E:\FrameWork\yii2\advanced\vendor\yiisoft\yii2\db\BaseActiveRecord.php(635): yii\db\ActiveRecord->insert(false, NULL)
#5 E:\www\phpfetcherTest\widget\AdminListConfig.php(63): yii\db\BaseActiveRecord->save(false)
#6 E:\www\phpfetcherTest\logic\BaseController.php(66): app\widget\AdminListConfig::showCreate(Object(app\controllers\ArticleController), false, false, false, true)
#7 [internal function]: app\logic\BaseController->actionCreate()
#8 E:\FrameWork\yii2\advanced\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array(Array, Array)
#9 E:\FrameWork\yii2\advanced\vendor\yiisoft\yii2\base\Controller.php(156): yii\base\InlineAction->runWithParams(Array)
#10 E:\FrameWork\yii2\advanced\vendor\yiisoft\yii2\base\Module.php(523): yii\base\Controller->runAction('create', Array)
#11 E:\FrameWork\yii2\advanced\vendor\yiisoft\yii2\web\Application.php(102): yii\base\Module->runAction('article/create', Array)
#12 E:\FrameWork\yii2\advanced\vendor\yiisoft\yii2\base\Application.php(380): yii\web\Application->handleRequest(Object(yii\web\Request))
#13 E:\www\phpfetcherTest\web\index.php(19): yii\base\Application->run()
#14 {main}
共 3 条回复
lamp9
注册时间:2017-07-13
最后登录:2017-12-26
在线时长:1小时21分
最后登录:2017-12-26
在线时长:1小时21分
- 粉丝0
- 金钱35
- 威望0
- 积分45