Home > Backend Development > PHP Tutorial > ThinkPHP+Mysql关联模型求助

ThinkPHP+Mysql关联模型求助

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:28:14
Original
1198 people have browsed it

有两张表,userpic表是图片上传的表,dynamic表是用户发布的动态列表,dynamic里面的userpic_id字段的各个值对应userpic表的id
dynamic表里的userpic_id字段有字符串:5,4,3,1,2

1.怎样做才能把字符串里的各个id与userpic表的id关联起来呢?
2.是怎样的关联,一对多还是多对多?

ThinkPHP+Mysql关联模型求助

ThinkPHP+Mysql关联模型求助

回复内容:

有两张表,userpic表是图片上传的表,dynamic表是用户发布的动态列表,dynamic里面的userpic_id字段的各个值对应userpic表的id
dynamic表里的userpic_id字段有字符串:5,4,3,1,2

1.怎样做才能把字符串里的各个id与userpic表的id关联起来呢?
2.是怎样的关联,一对多还是多对多?

ThinkPHP+Mysql关联模型求助

ThinkPHP+Mysql关联模型求助

查询表的时候直接where uid in 不就行了,一对多还是多对多看你项目需求了。但多对多管理起来比较麻烦。

Related labels:
php
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template