获取mysql条目的CHAR_LENGTH作为php变量

[英]Get CHAR_LENGTH of mysql entry as a php variable


Thanks in advance for any help!

在此先感谢您的帮助!

I have several different mysql columns (which are imported from a product feed) that I'm trying to convert into one to work with a custom plugin for Opencart.

我有几个不同的mysql列(从产品Feed导入),我正在尝试将其转换为一个用于Opencart的自定义插件。

The format of the MYSQL entry for the plugin is as follows...

插件的MYSQL条目格式如下......

a:11:{i:13;s:3:"964";i:14;s:9:"Automatic";i:15;s:3:"FWD";i:16;s:15:"Gas I6 4.2L/256";i:17;s:5:"Black";i:18;s:4:"Gray";i:19;s:12:"Some City, ST";i:20;s:2:"15";i:21;s:2:"21";i:22;s:6:"128365";i:23;s:17:"2XXXXG3XXXXH5XXXX";}

As you can see, the "s:X" represents the character count for each entry. I have 11 different columns with the info I'm trying to convert to this format, but without an accurate character count the plugin throws an error. So i'm trying to use a combo of sql/php to get an accurate character count that I can use to make this work. I have a handle on everything else.

如您所见,“s:X”表示每个条目的字符数。我有11个不同的列,我想要转换为这种格式的信息,但如果没有准确的字符数,插件会抛出错误。所以我正在尝试使用sql / php的组合来获得一个准确的字符数,我可以使用它来完成这项工作。我掌握了其他一切。

SO!

My question is...how do I assign the character count to a variable? I did some googling and I found this...

我的问题是......如何将字符数分配给变量?我做了一些谷歌搜索,我发现这...

SELECT CHAR_LENGTH('TABLENAME');

I realize there's more to it, just wondering how to set it as a variable.

我意识到还有更多,只是想知道如何将其设置为变量。

AND

Not terribly important, but does anyone recognize the format? I've never seen this before! Serialized PHP Array

不是很重要,但是有人认出这种格式吗?我以前从未见过这个!序列化的PHP数组

1 个解决方案

#1


0  

Not sure if this will help anyone in the future since this is pretty specific, but based on the info I got from jraede (thanks alot!). I was able to load all 11 columns into a PHP array and serialize, then upload to DB. WAY easier than trying to create 11 variables for character count!

不确定这是否会对未来的任何人有所帮助,因为这是非常具体的,但是基于我从jraede获得的信息(非常感谢!)。我能够将所有11列加载到PHP数组中并序列化,然后上传到DB。比尝试为字符数创建11个变量更容易!


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2013/06/20/3a6a0e21d9f33d6329770b2d1a3f41fe.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号