-
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
Bug: [QueryBuilder] unable to use regular expression inside a query using module class #4355
Comments
The only way is the use of Regular Query as describe in documentation. $result = $this->query("SELECT REGEXP_SUBSTR(ral_anno,\"[0-9]{1,2}([,.][0-9]{1,3})([,.][0-9]{1,3})\") AS ral, ral_anno FROM `ob_human_resources` WHERE period = '".$period."-01-01' AND livello LIKE '%".trim($livello)."%' ORDER BY ral DESC")->getResult(); Only in this way query work fine. |
Yes. A regular query call is your workaround for this. The issue arises when using a SELECT string with commas in it. CI4 will just blindly explode the string at the commas. |
At the moment, the problem has not yet been resolved.
|
I think we need to make it clear what the second parameter If I design it from the scratch,
|
CI 3.1-stable: $sql = $this->db->select('REGEXP_SUBSTR(ral_anno,"[0-9]{1,2}([,.][0-9]{1,3})([,.][0-9]{1,3})") AS ral', false)
->get_compiled_select('ob_human_resources'); SELECT REGEXP_SUBSTR(ral_anno, "[0-9]{1, 2}([, .][0-9]{1, 3})([, .][0-9]{1, 3})") AS ral
FROM "ob_human_resources" |
It seems that the parameter So if |
I created a PR #5817 |
Describe the bug
If you use a regular expression inside a query C4 add ` and space unwanted.
CodeIgniter 4 version
^4
Affected module(s)
CodeIgniter\Model
Expected behavior, and steps to reproduce if appropriate
If you write a query like this:
the final result is:
The problem is in regular expression:
[0-9]{1, 2}([, .
][0-9]{1
, 3})([, .][0-9]{1
, 3}) -> this is not original one i write.` and space are added
Following documentation i also try to add second parameter to select
the result is no ` and it's ok but space are also added:
Context
The text was updated successfully, but these errors were encountered: