本文整理匯總了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;
}