· 6 years ago · Jun 26, 2019, 08:58 AM
1INSERT INTO berichten_devices (device_UUID, article_id) VALUES (%s, %s)
2
3INSERT INTO berichten_devices (device_UUID, article_id) VALUES ('test', 1)
4
5function insert_artice_read($uuid, $article_id) {
6error_log('$uuid:'.$uuid, 0);
7error_log('$article_id:'.$article_id, 0);
8
9 $query = "INSERT INTO berichten_devices (device_UUID, article_id) VALUES (%s, %s)";
10error_log('$query', 0);
11error_log($query, 0);
12 $query = $this->wpdb->prepare($uuid, $article_id);
13 return $this->wpdb->query($query);
14 }
15
16$this->wpdb = $wpdb;
17
18dcr-wordpress | [Tue Jun 25 10:45:03.363771 2019] [php7:notice] [pid 1953] [client 192.168.224.1:43584] $uuid:ABCDEF01-2345-6789-ABCD-9876543210AA
19dcr-wordpress | [Tue Jun 25 10:45:03.363776 2019] [php7:notice] [pid 1953] [client 192.168.224.1:43584] $article_id:1
20dcr-wordpress | [Tue Jun 25 10:45:03.363781 2019] [php7:notice] [pid 1953] [client 192.168.224.1:43584] $query
21dcr-wordpress | [Tue Jun 25 10:45:03.363785 2019] [php7:notice] [pid 1953] [client 192.168.224.1:43584] INSERT INTO berichten_devices (device_UUID, article_id) VALUES (%s, %s)
22dcr-wordpress | [Tue Jun 25 10:45:03.364844 2019] [php7:notice] [pid 1953] [client 192.168.224.1:43584] 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 'ABCDEF01-2345-6789-ABCD-9876543210AA' at line 1 bij query ABCDEF01-2345-6789-ABCD-9876543210AA gemaakt door require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, rest_api_loaded, WP_REST_Server->serve_request, WP_REST_Server->dispatch, Prop\Inc\Core\RestController->article_retrieved, Prop\Inc\Common\Repository->insert_artice_read
23dcr-wordpress | 192.168.224.1 - - [25/Jun/2019:10:45:03 +0000] "POST /wp/wp-json/prop/v1/berichten-devices HTTP/1.1" 200 802 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
24
25for the right syntax to use near 'ABCDEF01-2345-6789-ABCD-9876543210AA'
26
27for the right syntax to use near %s
28
29CREATE TABLE IF NOT EXISTS berichten_devices (
30 device_UUID VARCHAR(255) NOT NULL,
31 article_id int(10) NOT NULL,
32 date timestamp(4) NOT NULL DEFAULT CURRENT_TIMESTAMP(4),
33
34 KEY `dev_uuid` (device_UUID)
35
36$query = "INSERT INTO berichten_devices (device_UUID, article_id) VALUES ('%s', '%s')";
37
38function insert_artice_read($uuid, $article_id) {
39error_log('$uuid:'.$uuid, 0);
40error_log('$article_id:'.$article_id, 0);
41
42 $this->wpdb->query($this->wpdb->prepare("INSERT INTO berichten_devices (device_UUID, article_id) VALUES (%s, %s)", $uuid, $article_id));
43
44 }