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

obey table prefix, if defined in database connection #365

Merged
merged 1 commit into from
Jan 6, 2022

Conversation

thyseus
Copy link
Collaborator

@thyseus thyseus commented Dec 24, 2021

No description provided.

@marksalmon
Copy link
Collaborator

Thanks,

I haven't used table prefixes in Laravel before.

Do you not need to concatenate an extra '.' between the prefix and the column name?

$query->whereRaw('LOWER(' . ($this->tablePrefix ? $this->tablePrefix . '.' : '') . $column . ') like ?', [mb_strtolower("%$value%")]);

instead of:

$query->whereRaw('LOWER(' . $this->tablePrefix . $column . ') like ?', [mb_strtolower("%$value%")]);

@thyseus
Copy link
Collaborator Author

thyseus commented Jan 6, 2022

Actually having a . inside a sql table name is very uncommon. Never encountered that in my life. _ is common. I am not even sure if SQL supports that. If you need a . inside your sql tables you would write it in your variable like TABLE_PREFIX=prefix..

I use this code in a project already in production :)

@marksalmon
Copy link
Collaborator

marksalmon commented Jan 6, 2022 via email

@marksalmon marksalmon merged commit 098fb1b into MedicOneSystems:master Jan 6, 2022
@zachary
Copy link

zachary commented Jan 12, 2022

Could you please let me how to fix the issue? thanks

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

Successfully merging this pull request may close these issues.

3 participants