在数据库中存储数组的问题 [英] Problem storing array in database

查看:65
本文介绍了在数据库中存储数组的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用逗号分隔值在文本框中从用户那里获取技能。例如:关键技能:C,C ++,Java

现在我已经使用explode函数将这个vaues存储到名为arrSkills的数组中。现在,在将它们输入数据库之前,我首先检查tagmaster表中是否已在表中存在标记名为arrSkills的情况。如果存在,我选择相应标记名的tagId。如果它不存在,那么我首先将arrSkills插入到tagmaster中,然后选择它的tagId。选择TagId后,我将tagId和username输入usertags表。这里的问题是它输入tagId作为在KeySkill中输入的元素数量,即上面的示例为3,tagname为tagmaster作为数组,并使usertags表变为无限值。

这是我用过的代码。 Plz检查错误并告诉我。


Hi,
I have taken skills form the user in a text box using comma separated values. For eg: Key Skills: C,C++,Java
Now i have stored this vaues into array named arrSkills using explode function. Now before entering them into database i first check in the tagmaster table if already a tagnamed arrSkills exists in the table. If it exists i select the tagId of the corresponding tagname. If it doesnt exists then i first insert that arrSkills into tagmaster and then select its tagId. After the TagId is selected i enter the tagId and username into usertags table. The problem here is that it enters the tagId as the number of elements entered in KeySkill i.e. 3 for above example and tagname as Array in tagmaster table and makes the usertags table go to infinite value.
This is the code that i have used. Plz check out the error and let me know.


展开 | 选择 | Wrap | 行号

推荐答案

如果您愿意,我们会很高兴我们时不时地知道,在这个论坛中给你的建议和代码实际上是在使用或实施的,或者是实现了解决方案或提示。


我们的会员在很多场合帮助你,在业余时间自由地做这件事。有些问题需要花费大量时间进行调查。


我所看到的是,我们的成员足以输入众多建议/解决方案甚至代码集,但他们从未听过结果他们的努力。这让人有点警惕。


Ronald
It would be nice if you would let us know, every now and then, that the advice and the code that was given to you in this forum, was actually used or implemented or that a solution or hint was implemented.

Our members help you out on a lot of occasions, doing this freely, in their spare time. Some problems cost a lot of time to investigate.

All I see is that our members are good enough to enter numerous advices/solutions and even sets of code, but they never hear the result of their efforts. That makes people of bit wary.

Ronald


对不起,非常感谢。每一个建议,提示和解决方案都有助于我在项目中实施。

非常感谢。
Sorry and thanks a lot. Each and every advice, hint and solution helps me alot in implementin my project.
Thanks a lot.


好的,谢谢。至于你的问题:


explode函数构造一个数组,所以当你指定结果是一个数组时。 n您无法在数据库字段中插入数组。
Ok and thank you. As to your problem:

The explode function constructs an array, so when you assign that the result is an array. nAnd you cannot insert an array in a db field.

返回一个字符串数组,每个字符串都是字符串的子字符串,通过在字符串分隔符
Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string delimiter

$形成的边界上将其拆分而形成b
$ b那么从你的第一个声明中你对这个数组的意图是什么?


Ronald

So what is your intention with that array from your first statement?

Ronald


这篇关于在数据库中存储数组的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆