Skip to content

How would you use prepared statement ? within quotes? #1048

Open
@mark8044

Description

@mark8044

Im trying to convert the following string

x[mark8044][userid:12345] into ==> x[newusername][userid:12345]

But something is not working here, I have a feeling it has to do with trying to put the prepared statement ? that sites within a quote '

$userid = 12345;
$oldusername = 'mark8044';
$newusername = 'newusername';



        $db->rawQuery("
                    UPDATE texthistory 
                    SET texthistory = REPLACE(pagetext, 'x['?'][userid:'?']', '@['?'][userid:'?']') 
                    WHERE texthistory LIKE '%@['?'][userid:'?']%' 
                    AND userid = ?", Array($oldusername,$userid,$newusername, $userid, $oldusername, $userid));

Removing the quotes does not seem to work either


        $db->rawQuery("
                    UPDATE texthistory 
                    SET texthistory = REPLACE(pagetext, 'x[?][userid:?]', '@[?][userid:?]') 
                    WHERE texthistory LIKE '%@[?][userid:?]%' 
                    AND userid = ?", Array($oldusername,$userid,$newusername, $userid, $oldusername, $userid));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions