-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat: QueryBuilder raw SQL string support #5817
Conversation
6b94ae9
to
a7ab894
Compare
Is it possible to add a second argument to the constructor to pass the binding? new RawSql('a = ? AND b = ?', [1, 2]);
new RawSql('a = :a AND b = :b', ['a'=>1, 'b' => 2]); |
@iRedds I'm not sure. Can you tell me what's good if it is possible? |
Usage example above. For example, for such a query (from #5810 ) $builder->orLike("(SELECT COALESCE(GROUP_CONCAT(CONCAT(corr.description, ' ', corr.note) ORDER BY corr.order_field ASC SEPARATOR ' '), '') FROM correspondence corr WHERE corr.contact_fk = c. contact_id AND 1 = 1)", "", "both", false); Although this query does not use value substitution, this is a possible situation. |
8699ada
to
a1eabc7
Compare
@iRedds What's about escaping? |
It seems to me that there are two options without using DBC
|
I do not see much need for binding, so I will not include it in this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this solution is fine, and I don't see an issue with leaving binds out. Being raw SQL I don't think that's unexpected. Thanks @kenjis
But it does need docs added.
I added docs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that the $escape
parameter would do the trick for this type of scenario but I guess I was wrong. I think it is a good addition.
@michalsn Thank you! |
Related: #4355, #3970, #5810
Description
See https://forum.codeigniter.com/showthread.php?tid=80720
RawSql
classselect()
supportsRawSql
where()
supportsRawSql
like()
supportsRawSql
Checklist: