我的网址是:http://localhost/intranet/customers/search/1/1A%3A79%3A32%3A97%3AF2/1 我按如下方式打印params对象:
print_r($this->params);
这将打印以下数组:
[params] => Array
(
[plugin] =>
[controller] => customers
[action] => search
[named] => Array
(
[1A] => 79:32:97:F2
)
[pass] => Array
(
[0] => 1
[1] => 1
)
)
但它应该打印:
[params] => Array
(
[plugin] =>
[controller] => customers
[action] => search
[named] => Array
(
)
[pass] => Array
(
[0] => 1
[1] => 1A:79:32:97:F2
[2] => 1
)
)
但是当我更改网址时:http://localhost/intranet/customers/search/1/abc/1
[params] => Array
(
[plugin] =>
[controller] => customers
[action] => search
[named] => Array
(
)
[pass] => Array
(
[0] => 1
[1] => abc
[2] => 1
)
)
1A:79:32:97:F2中哪个问题作为url中的参数?
答案 0 :(得分:2)
您需要禁用命名参数解析的贪婪,默认情况下,所有看起来像命名参数的参数都会被解析(即包含create table #t
(
[ID] int,
[Date] date,
[Name] varchar(5)
)
insert into #t
values
(1, getdate(),'1-1'),
(2, dateadd(D,-10,getdate()),'2-1'),
(2, dateadd(D,-5,getdate()),'2-2'),
(1, dateadd(M,-1,getdate()),'1-2')
select [1], [2]
from ( select ID, [Name] from #t ) y
pivot (
max(y.[Name])
for y.ID in ([1],[2])
) pvt;
drop table #t
分隔符的值)。
在你的路由配置中,使用:
的第二个参数传递更多选项,类似于这一点,这将只启用默认的CakePHP分页参数:
Router::connectNamed()
另见