Skip to content
Advertisement

Whats the right syntax to CONCAT in wpdb?

I’m quiet new in working with wordpress database tables. So far I know because of the wpdb documentation how to update a row in a table. Now i want to achive to update the row and keep the old data in that row. I’ve read that you can use the CONCAT function to get this working but I’ve no clue how the exact syntax should look like.

That’s my current approach:

$wpdb->update($wpdb->prefix .'logins', check_in_out_log = CONCAT(check_in_out_log, ' ', '30.07.2021 11:00'), array('id' => $user_id)) === false)

Advertisement

Answer

Alright… Got it! I’m not sure but I think it’s not possible with $wpdb->update so I’ve created a $wpdb->query and used normal sql commands.

$wpdb->query($wpdb->prepare("UPDATE logins SET check_in_out_log = CONCAT(check_in_out_log, ' 30.07.2021 11:00') WHERE id = '%s'", $ticket_id));
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement