Wednesday, 15 July 2015

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 any product feed) that I am trying to convert to one with OpenCart to work with custom plugin .

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

  one: 11: {i: 13key: 3: "964", i : 9: "automated"; I: 15K: 3: "FWD"; Me: 16K: 15: "Gas I6 4.2L / 256"; I: 17; S: 5: "black"; I: 18; S: 4: "gray"; I: 19; S: 12: "Some Cities, 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, "s: X" represents the character count for each entry. I have 11 different columns with which I am trying to convert to this format, but without calculating an exact character the plugin throws an error, so I get sql / php combo to get an exact character count I am trying to use that which I can use to do this work. I have a handle on everything.

So!

My question is ... how do I calculate the character in a variable? I did some googling and I found this ...

  select CHAR_LENGTH ('tabym');   

I realize that this is even more for it, just wondering how to set it as a variable.

and

Not very important, but does anyone recognize the format? I've never seen it before! Serialized PHP array

Not sure if it will help someone in the future I am able to load all 11 columns in a PHP array and serialize, then upload it to DB. Easy way to try to make 11 variables for character count!

No comments:

Post a Comment