以下是我的型号代码,
public function insertme()
{
$sel = new Sql($this->adapter);
$s = $sel->insert('users');
$data = array(
'fname'=>'fisdsds',
'lname'=>'sdsdsdme',
'email'=>'sdsdsds',
'pword'=>'dsdsds'
);
$s->values($data);
$statement = $sel->prepareStatementForSqlObject($s);
$comments = $statement->execute();
$resultset = new ResultSet();
$resultset->initialize($comments);
$result = $resultset->toArray();
//print_R($result);
return $result;
}
它正在将数据插入数据库表users
,但我也收到错误SQLSTATE[HY000]: General error
可能是什么问题?
答案 0 :(得分:1)
没有必要尝试从插入中创建ResultSet,它不会返回任何结果集数据。
public function insertme()
{
$sel = new Sql($this->adapter);
$s = $sel->insert('users');
$data = array(
'fname'=>'fisdsds',
'lname'=>'sdsdsdme',
'email'=>'sdsdsds',
'pword'=>'dsdsds'
);
$s->values($data);
$statement = $sel->prepareStatementForSqlObject($s);
$result= $statement->execute();
//print_R($result);
return $result;
}