hemachandra
(Hemachandra Gaaja)
1
Hi All,
i need your help in passing a varchar in URL in-place of id
This is my UrlManager rule i am using
'<module:media>/<id:\d+>' => '<module>/default/view',
and when i am passing my URL as
localhost/media/23trt4 i am getting error saying "The system is unable to find the requested action"
Rule, i have written works fine for "int values". But when i am sending as varchar, i am not able to get that. Can anyone help me to fix this issue??
mdomba
(Maurizio Domba Cerin)
2
in the part "[color=#1C2837][size=2]<id:\d+>" the \d+ means decimal… try with \w instead[/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2]also check the documentation regarding the regex syntax - [/size][/color][color="#1c2837"][size=2]http://php.net/manual/en/regexp.reference.escape.php[/size][/color]
hemachandra
(Hemachandra Gaaja)
3
thanks, its working fine now. I was trying with "<action: \w+>".
mdomba
(Maurizio Domba Cerin)
4
you don’t need +…
\d means one digit so + is needed with it to allow a number with more digits…
while \w means one word… with a + it would mean more words.
again check the doc for this here - http://php.net/manual/en/regexp.reference.meta.php
softark
(Softark)
5
??
\w should mean a character that can be used in "word".
http://php.net/manual/en/regexp.reference.escape.php