Home  >  Article  >  Backend Development  >  php中的url规则是怎么写入到数据库的

php中的url规则是怎么写入到数据库的

WBOY
WBOYOriginal
2016-06-13 12:16:031363browse

php中的url规则是如何写入到数据库的?
比如我定义好文章的url规则为

post/{$id}.html

{$id}表示的是文章id

写入的数据库的语句应该怎么写,因为{$id}也是数据表中的字段id的值,如果单纯的写id,只需要VALUES中值写 `id`即可,现在是字符串跟字段id混合着,就不知道怎么写了
我试过
concat('post/',`id`,'.html')

但当url规则变化时,这里又要重新设置,感觉不是很灵活

像PHPCMS中,url规则设定好后,又是怎么更新都数据库中的呢?
------解决思路----------------------
这个规则肯定是独立数据表,而不是像这样有多少新闻就写多少遍
表rules
id    category    rule
1     news         post/{ID}.html
使用时搜news找到规则,然后用str_replace替换掉{ID}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn