Using function REPLACE in querybuilder

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • murray99
    Member
    • Jan 2017
    • 57

    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
  • murray99
    Member
    • Jan 2017
    • 57

    #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


    • esforim
      esforim commented
      Editing a comment
      You might want to use the [code] tag from the forum. Your post showing happy face emoji at the moment.
  • yuri
    Member
    • Mar 2014
    • 8440

    #3
    I've added Expression support to the UpdateBuilder.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    Working...