Wordpress "wpdb->update" - Append Text Value

admin2025-04-19  0

I am trying to update a table column by appending some text to the existing value in the column.

Basically, I am trying to do something like this:

  $wpdb->update('table_name',
                array('notes' => notes + 'some text here to append'))
               ,array('note_id' => 313)
               );

Is this possible?

I am trying to update a table column by appending some text to the existing value in the column.

Basically, I am trying to do something like this:

  $wpdb->update('table_name',
                array('notes' => notes + 'some text here to append'))
               ,array('note_id' => 313)
               );

Is this possible?

Share Improve this question asked Oct 23, 2019 at 18:18 mannyotrmannyotr 174 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Short answer: it's not possible.

Long answer: you should try $wpdb->query instead and write a regular SQL query, something like this:

UPDATE table_name SET notes = CONCAT(notes, 'text to append') WHERE note_id = '313'

Please note it's only an example and you should use $wpdb->prepare to also sanitize variables properly.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745058211a282533.html

最新回复(0)