Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert a velocity array [x, y, z] into a string to be stored in a database?

I'm trying to store a velocity vector declared as this:

 me.vel = [0, 0, 0];

into a MySQL database. I assume this needs to be converted into a string before it can be stored, but that's because I don't know of any appropriate type to store it as, ex: VARCHAR, INT, STRING, etc. (If it can be stored let me know which type as this would be a simpler solution and I wouldn't have to convert into a string then back to a vector)

I've tried:

 var velocityString = me.vel.join();
 var velocityString = String(me.vel);

but those don't seem to work.

How can I convert this array into a string?

Thanks, Digimas

like image 686
user671891 Avatar asked Dec 20 '25 22:12

user671891


1 Answers

Or you could json encode the object.

like image 156
Christopher Roy Avatar answered Dec 22 '25 11:12

Christopher Roy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!