Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPLACE with column name #1034

Open
dezertdezine opened this issue Feb 4, 2022 · 0 comments
Open

REPLACE with column name #1034

dezertdezine opened this issue Feb 4, 2022 · 0 comments

Comments

@dezertdezine
Copy link

I'm currently doing this:

$posted_data['telephone'] = '123456789';

$where['OR'] = [
    'telephone_office[~]' => $posted_data['telephone'],
    'telephone_mobile[~]' => $posted_data['telephone'],
    'telephone_home[~]'   => $posted_data['telephone'],
];

...which results in this:

WHERE (
    (`telephone_office` LIKE '%123456789%') 
    OR (`telephone_mobile` LIKE '%123456789%') 
    OR (`telephone_home` LIKE '%123456789%')
)

...BUT I want to achieve this:

WHERE (
    (REPLACE(`telephone_office`, ' ', '') LIKE '%123456789%') 
    OR (REPLACE(`telephone_mobile`, ' ', '') LIKE '%123456789%') 
    OR (REPLACE(`telephone_home`, ' ', '') LIKE '%123456789%')
)

Any suggestions how to do so safely?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant