本文整理汇总了PHP中phpbb\db\driver\driver_interface::get_sql_error_returned方法的典型用法代码示例。如果您正苦于以下问题:PHP driver_interface::get_sql_error_returned方法的具体用法?PHP driver_interface::get_sql_error_returned怎么用?PHP driver_interface::get_sql_error_returned使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\db\driver\driver_interface
的用法示例。
在下文中一共展示了driver_interface::get_sql_error_returned方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: like
public function like($post_id)
{
if ($this->user->data['user_type'] != 1 and $this->user->data['user_type'] != 2) {
$json_response = new \phpbb\json_response();
$user_id = $this->user->data['user_id'];
if ($post_id and $user_id) {
$this->db->sql_query("INSERT INTO " . $this->table_prefix . "post_likes (`post_id`, `user_id`)\n\t\t\t\t\tVALUES ('" . $post_id . "', '" . $user_id . "')");
$err = $this->db->get_sql_error_returned();
if ($err['code'] == 1062) {
$json_response->send(['status' => 'already liked']);
}
}
$json_response->send(['status' => 'ok', 'postId' => $post_id, 'message' => $this->getLikeMessage($this->request->variable('like_opt', 'opt2'))]);
}
}
示例2: sql_query
/**
* Wrapper for running queries to generate user feedback on updates
*
* @param string $sql SQL query to run on the database
* @return mixed Query result from db->sql_query()
*/
protected function sql_query($sql)
{
$this->queries[] = $sql;
$this->db->sql_return_on_error(true);
if ($sql === 'begin') {
$result = $this->db->sql_transaction('begin');
} else {
if ($sql === 'commit') {
$result = $this->db->sql_transaction('commit');
} else {
$result = $this->db->sql_query($sql);
if ($this->db->get_sql_error_triggered()) {
$this->errors[] = array('sql' => $this->db->get_sql_error_sql(), 'code' => $this->db->get_sql_error_returned());
}
}
}
$this->db->sql_return_on_error(false);
return $result;
}