新手请问数据库为字符串的情况下PHP怎么读取

WBOY
Release: 2016-06-13 11:54:32
Original
800 people have browsed it

新手请教数据库为字符串的情况下PHP如何读取?

本帖最后由 c520zf1986 于 2014-04-01 10:44:39 编辑 例一:MYSQL数据库某字段一行的内容为:1,22,31,46,85,61,7
这样的格式,用PHP如何读取和进行更新保存?
如果我指定要要读取第四个数字,也就是46,PHP格式怎么写?如果我要读取第一个和最后一个数字,格式又怎么写?如果我需要在最后一个数字后面再添加一个又如何?

例二,另外一字段的内容为:a:20,b:55,i:75
这样的格式又如何读取和进行更新呢?
------解决方案--------------------
select SUBSTRING_INDEX(SUBSTRING_INDEX('1,22,31,46,85,61,7',',',4),',',-1) as 第四个
Copy after login
第四个 
46 

用 php 需要读取后拆分成数组

你这是自己给自己找麻烦,看似节省了空间,却又浪费了时间和脑细胞
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template