3.2.3 - 普通 - 未处理
public function save(&$info){
if (!$info[$this->tablename.'_id'] || $info[$this->tablename.'_id'] <=0)
{
/* 添加一条记录,并把返回的ID插入到$info里 */
$id = $this->modelCs->add($info);
$info[$this->tablename.'_id'] = $id;
return $id;
} else { // 更新
return $this->modelCs->save($info);
}
}
$this->modelCs = D(CONTROLLER_NAME);
A('Bind')->bind($site, $userId); // A方法调用
public function bind($site, $userId)
{
/* baidu绑定 */
if ($site == 'baidu')
{
/* 获取百度用户信息 */
Vendor('Baidu.Api#class');
$baiduApi = new \Baidu\Api();
$binduser = $baiduApi->getUserInfo(); // 获取用户信息
if ($binduser['errmsg']) return 0;
$bind['bind_state'] = 1;
$bind['bind_uid'] = $binduser['userid'];
$bind['bind_bindtime'] = time();
$bind['user_id'] = $userId;
$bind['site_id'] = 2;
D('Bind')->save($bind); // 可以正常保存
return $this->modelCs->save($bind); // 保存失败下面是错误信息
}
return 0;
}
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `user_id` = 1' at line 1
