开发者

Why in mysql store data like this a:6:{s:5:"title";s:43:}

开发者_Python百科

In mysql database , I find some data store like below:

a:6:{s:5:"title";s:43:"fgjfh";s:8:"province";s:6:"重庆";s:4:"city";s:9:"大渡口";s:8:"location";s:6:"fhfghf";s:9:"starttime";s:11:"09-02 12:00";s:7:"endtime";s:11:"09-02 16:00";}


That's a PHP serialized array. You serialized your array before putting it to the database.

Look for serialize($value) calls in your code if you want to change it.

Update:

Probably your stored data (which is a hash actually) has dynamic fields, and it was too difficult for the creator or he/she didn't care/was lazy to do so/decided that's not important or simply that was not the use case.

But you should consider to rethink your schema and create a correct (3NF) normalization. In this case you will have at least one table which can be like this:

CREATE TABLE data (
  id          INTEGER PRIMARY KEY, -- or SERIAL if your database supports it
  title       VARCHAR,             -- or TEXT
  province_id INTEGER NOT NULL,    -- or REFERENCES the provinces table
  city_id     INTEGER NOT NULL,    -- or REFERENCES the cities table
  location    VARCHAR,             -- I do not really know what is this field
  starttime   TIMESTAMP,
  endtime     TIMESTAMP
);

And of course your you'll need the provinces and the cities tables as well. With this schema you could use database instructions to work with the stored data if you need so.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜