模板内部用add无法添加到数据库,各种方法都用了 求高人指定 本人初学

浏览:889 发布日期:2013/04/05 分类:求助交流
$articlesave=new ArticleModel();
$articlesave->title=$_POST['title'];
$articlesave->author=$_POST['author'];
$articlesave->content=$_POST['content'];
$articlesave->mid=$_POST['mid'];
$result=$articlesave->add();
if(TRUE==$result){
$this->success("insert success",index);
}else{
dump($articlesave);
}
上面这是插入代码

object(ArticleModel)#4 (20) {
["_auto:protected"] => array(1) {
[0] => array(4) {
[0] => string(4) "date"
[1] => string(7) "getDate"
[2] => int(1)
[3] => string(8) "callback"
}
}
["_extModel:private"] => NULL
["db:protected"] => object(DbMysql)#6 (17) {
["dbType:protected"] => string(5) "MYSQL"
["autoFree:protected"] => bool(false)
["model:protected"] => string(7) "_think_"
["pconnect:protected"] => bool(false)
["queryStr:protected"] => string(119) "INSERT INTO `sau_zsjy_article` (`title`,`author`,`content`,`mid`) VALUES ('fasas','asfafa','<p>璇疯緭鍏�...</p>\r\n',1)"
["modelSql:protected"] => array(1) {
["Article"] => string(119) "INSERT INTO `sau_zsjy_article` (`title`,`author`,`content`,`mid`) VALUES ('fasas','asfafa','<p>璇疯緭鍏�...</p>\r\n',1)"
}
["lastInsID:protected"] => NULL
["numRows:protected"] => int(7)
["numCols:protected"] => int(0)
["transTimes:protected"] => int(0)
["error:protected"] => string(166) "Duplicate entry '0' for key 1
[ SQL璇彞 ] : INSERT INTO `sau_zsjy_article` (`title`,`author`,`content`,`mid`) VALUES ('fasas','asfafa','<p>璇疯緭鍏�...</p>\r\n',1)"
["linkID:protected"] => array(1) {
[0] => resource(27) of type (mysql link)
}
["_linkID:protected"] => resource(27) of type (mysql link)
["queryID:protected"] => NULL
["connected:protected"] => bool(true)
["comparison:protected"] => array(10) {
["eq"] => string(1) "="
["neq"] => string(2) "<>"
["gt"] => string(1) ">"
["egt"] => string(2) ">="
["lt"] => string(1) "<"
["elt"] => string(2) "<="
["notlike"] => string(8) "NOT LIKE"
["like"] => string(4) "LIKE"
["in"] => string(2) "IN"
["notin"] => string(6) "NOT IN"
}
["selectSql:protected"] => string(96) "SELECT%DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%%ORDER%%LIMIT% %UNION%%COMMENT%"
}
["pk:protected"] => string(2) "id"
["tablePrefix:protected"] => string(9) "sau_zsjy_"
["name:protected"] => string(7) "Article"
["dbName:protected"] => string(0) ""
["connection:protected"] => string(0) ""
["tableName:protected"] => string(0) ""
["trueTableName:protected"] => string(16) "sau_zsjy_article"
["error:protected"] => string(0) ""
["fields:protected"] => array(10) {
[0] => string(2) "id"
[1] => string(5) "title"
[2] => string(6) "author"
[3] => string(7) "content"
[4] => string(4) "date"
[5] => string(3) "mid"
[6] => string(4) "link"
["_autoinc"] => bool(false)
["_pk"] => string(2) "id"
["_type"] => array(7) {
["id"] => string(7) "int(11)"
["title"] => string(11) "varchar(40)"
["author"] => string(11) "varchar(20)"
["content"] => string(8) "longtext"
["date"] => string(4) "text"
["mid"] => string(7) "int(11)"
["link"] => string(4) "text"
}
}
["data:protected"] => array(0) {
}
["options:protected"] => array(0) {
}
["_validate:protected"] => array(0) {
}
["_map:protected"] => array(0) {
}
["_scope:protected"] => array(0) {
}
["autoCheckFields:protected"] => bool(true)
["patchValidate:protected"] => bool(false)
["methods:protected"] => array(10) {
[0] => string(5) "table"
[1] => string(5) "order"
[2] => string(5) "alias"
[3] => string(6) "having"
[4] => string(5) "group"
[5] => string(4) "lock"
[6] => string(8) "distinct"
[7] => string(4) "auto"
[8] => string(6) "filter"
[9] => string(8) "validate"
}
}
这是 用dump 显示的 请高手指点哪里错了
最佳答案
评论( 相关
后面还有条评论,点击查看>>