English 中文(简体)
Querying JSON dbbject from mysql in php
原标题:Querying JSON db objects from mysql in php

因此,我拿一口 app子,真心全意地向改变思想的客户致敬,因此,我决定把一些数据储存为名人。

一种配对系统,储存用户的Im,作为一组用户的JSON标本登记。

我想显示用户已经登记为我的过滤选择之一的所有匹配,因此,我基本上需要看到该用户的id是否储存在文本类型数据标中。

我认为这样做的两种方式是:

  1. 然后用<代码>in_array查询每件配对机和JSON-decode,看它们是否在配对机上(我没有这样做)。

  2. Just use a LIKE query to search the JSON text for "[userid]" (which is what I did).

Is there a better way to do something like this? Like does MySQL have a better built-in function for something like this?

最佳回答

试图在关系数据库(如MySQL)内将用户数据储存在JSON物体上是错误的。 你的数据库不是面向目标,而是联系的。 根据关系数据库规则,将很好地服务于你。 最好不要建立一个良好的数据库(DB)结构和进行准确的MySQL查询。

如果您至少保留第三种正常形式,你发现,当客户改变其思想(而不是......和......,以及......)时,你可以添加和改变用户特性,因为数据将保存在某个表格中,以便你能够增加和改变小型表格,而不给全系统带来巨大影响。

亚洲开发银行的另一个选择是建立一个具有各种特性的表格,其名称和价值为之。

问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签