Announcement

Collapse
No announcement yet.

Using function REPLACE in querybuilder

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using function REPLACE in querybuilder

    I want to do a replace in an update query.

    I can see the standard "set" bit which is normally like

    ->set(['myfield'=>$myvalue])

    but how do I use a function like REPLACE?

    Either with the function REPLACE: or using the expression builder Expr::replace
    Thanks

  • #2
    OK I found my own answer. There is an example at
    Espo\Tools\Kanban\OrdererProcessor

    line 158
    ->set(['order:' => 'ADDorder, ' . strval($offset) . ')'])​

    I assume that recognition of the value being set as a function is due to the key being
    order:
    not
    order

    So the colon on the key does the magic.

    so my code would be something like

    ->set(['myfield:'=>"REPLACE'haystack','stack','bail')"

    obviously this works for all the implemented functions:


    Comment


    • espcrm
      espcrm commented
      Editing a comment
      You might want to use the [code] tag from the forum. Your post showing happy face emoji at the moment.

  • #3
    I've added Expression support to the UpdateBuilder.

    Comment

    Working...
    X