Php 如何在URL codeigniter上将id替换为标题

Php 如何在URL codeigniter上将id替换为标题,php,codeigniter,Php,Codeigniter,请帮助我,我有一个问题,如何替换为标题id $data['title'] = site_url('controller/method').'/'.$title_param 第一个链接是:localhost/ci/index.php/product/productdetail/13 product = class productdetail = function 并已成功使用路由执行以下步骤 localhost/ci/index.php/produk/13 但我仍然没有找到将u

请帮助我,我有一个问题,如何替换为标题id

$data['title'] = site_url('controller/method').'/'.$title_param
第一个链接是:
localhost/ci/index.php/product/productdetail/13

product       = class

productdetail = function
并已成功使用路由执行以下步骤

localhost/ci/index.php/produk/13
但我仍然没有找到将url上的
id
更改为
title
的方法

localhost/ci/index.php/product/bed-cover

13``到
bed cover`

首先,您必须使您的标题字段在数据库中唯一。之后,您可以使用title进行查询

$data['title'] = site_url('controller/method').'/'.$title_param
或者你可以这样创建你的URL

 localhost/ci/index.php/product/productdetail/13/title
然后根据需要进行路由,甚至隐藏id(使用第三个uri段和查询)