Home Backend Development PHP Tutorial 问一个,小弟我也不知道是不是有关问题的有关问题

问一个,小弟我也不知道是不是有关问题的有关问题

Jun 13, 2016 pm 01:30 PM

问一个,我也不知道是不是问题的问题。
是一个分类的问题。

我看到某一网站上有这样的的分类

goods/catalog/dress/2000000000000 后面那一个数值2 代表的一个分类,这里只的是 dress(衣服)
goods/catalog/dress/2004000000000 2后面那一个数值4 代表的是dress(衣服)下面的一个子分类,这里只的是 裙子

如果在点一个大分类,就有可能是5000000000000 。7000000000000
比如
/goods/catalog/shoes/6000000000000
/goods/catalog/bag/5000000000000
/goods/catalog/access/7000000000000

我想知道的是,当然,我如果做一个分类 我就是一张表完成,里面加一个父ID来做成无限分类树,
而这里人家没有那样用,所以我就想问问,是不是它那样分类,比我用的分类好,还是它这样分,对它来说有特殊用途?有什么好处呢?



------解决方案--------------------
你也不知道人家表结构是否跟你一样把。只是构造url路径不同而已。
------解决方案--------------------
采用什么样的数据结构来存储分类,取决于对事物的认知和算法的复杂度
一旦数据结构被确定了,在想改变就异常困难了

你的分类树采用了邻接列表算法,无极限的很灵活。但要使用递归查询
他的分类采用的是位加权算法,商品分类是有限的,没必要搞的那么复杂
更何况分类字可直接定位的商品,也便于商品实体的管理
------解决方案--------------------
你那样也可啊。要想看得请先些。这样:/goods.php?type=2&pid=1 重写后就变成这样:/goods/1/2

或者学它那样。
------解决方案--------------------
我看了这个问题没有头绪。
还是用你自己的方法吧。人家的东西毕竟不能通过一个url就看出来了。
------解决方案--------------------
你自己配个重写就行了,何必模仿。
------解决方案--------------------

探讨

你自己配个重写就行了,何必模仿。

------解决方案--------------------
探讨

引用:

你自己配个重写就行了,何必模仿。

你又来这里看美女,推倒美女了,害我找了几个社区,翻了几百页帖子,终于找到你了。工头让我告诉你,明天去工地早些,要搬3车水泥两车砖头,如果搬不完,连昨天的工钱也不给你了

------解决方案--------------------
PHP code
$class = '100202';
$ar = sscanf($class, "%02s%02s%02s");
print_r($ar);
<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
探讨

引用:

引用:

你自己配个重写就行了,何必模仿。

你又来这里看美女,推倒美女了,害我找了几个社区,翻了几百页帖子,终于找到你了。工头让我告诉你,明天去工地早些,要搬3车水泥两车砖头,如果搬不完,连昨天的工钱也不给你了


-,- 被追随了,这下我火了。。
Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

See all articles