-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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] phalcon Does not support REGEXP and RLIKE in query model #2952
Comments
Why is this a bug? |
It is not a bug. It is something that would be nice to have. I will close the question from the forum with the same explanation. @akaNightmare use raw sql. |
hi , why phalcon ORM dos not support REGEXP and RLIKE ? |
akaNightmare solution is correct but we cant change model structure in some part . |
Implement your own dialect, as REGEXP and RLIKE are MySQL specific functions: |
I think REGEX is important. It certainly takes much time to implement REGEX for sqlite, postrgres and mysql. By the way if have PDO object for sqlite you have to FIRST define your own function handling REGEX param and expression which uses preg_replace (PCRE) or ereg (POSIX as in the case of mysql but ereg -like functions are deprecated in PHP). In phalcon in onConstruct method it could look like this (not tested and taken from stack overflow). $this->db->getInternalHandler()->sqliteCreateFunction('regexp', function() { Unfortunately REGEXP operator doesn't work whatever function i add using sqliteCreateFunction ("Syntax error, unexpected token IDENTIFIER(REGEXP)") but a function alone regexp(aaa, 'bbb') works - i mean it at least calls getSqlExpression method, but the REGEX operator doesn't, so it is not possible to process anything. I even don't say about postgress and mysql and something cross-db-engine. |
You can use custom functions to address this: https://blog.phalconphp.com/post/phalcon-2-0-3-released |
Thank you for your reply. By the way I've been able to resolve my problem using sql Like so far to compare numbers somewhere in the middle of text. You just can imagine the code for it was terrible so i need to replace it (it was in text f.e. ::tag_a::number::/tag_a::). |
This means not only this is not a bug, but also it shouldn't be implemented directly int raw sql. However, there could be a method like |
AWESOME !!!!!!!
When i try to execute a query using the mysql regexp, i get this error:
Syntax error, unexpected token IDENTIFIER(REGEXP), near to ' ",(4)," ', when parsing: SELECT [Multiple\Frontend\Models\Test].* FROM [Multiple\Frontend\Models\Test] WHERE kind REGEXP ",(4),"
like this error as open question :
http://forum.phalconphp.com/discussion/1193/select-query-by-regexp-error
#2532
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: