Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8275215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:59:57+00:00 2026-06-08T07:59:57+00:00

In my Lua application, I am trying to create a utility function that sets

  • 0

In my Lua application, I am trying to create a utility function that sets a specific user data. It uses this format: setUserData(int UID, string COLUMN_NAME, mixed ROWVALUE)
It saves the data in a MySQL database.

I’m not sure how to create the column (if it doesn’t exist) and detect the type of the value (TEXT, tinyint, VARCHAR etc) to set the column.

Would it be easier and better to always set the column as a TEXT type? If not, how can I detect and create?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:59:59+00:00Added an answer on June 8, 2026 at 7:59 am

    It very much depends on the contract of your setUserData function. If you expect users to always provide the same value type for a given column name, you might always derive some aspects of the column type from that, in particular whether it consists of characters, an integer or a floating point number. You could then choose to select the column type of maximal size for the given data, i.e. LONGTEXT, DOUBLE or BIGINT. Doing so might require more memory in the database than would strictly be neccessary, but if there really is nothing you know about the data passed to that function, you cannot rule out the possibility that all that space might be neded for some other value in the same column.

    An alternative approach would be to always choose the smallest data type from a given family. When inserting new data into an existing column, you’d have to look out for truncation warnings, and when you see them, you could enlarge the column type accordingly.

    For many applications, storing everything as character will be the simplest solution. But a LONGTEXT is far more complicated than a simple column type like TINYINT, so you’ll have to pay both in terms of memory requirements and performance. A VARCHAR isn’t as bad, so if you do the auto-enlarging suggested in the previous paragraph, the penalty will be less severe.

    Behaviour might also be slightly different when you store everything as text, independent from the native type in LUA: when you enter a number as '01234', it will compare unequal to '1234'. Whether this is desirable or not depends on your application, and might be a good indication whether storing your data as text is a good idea. As long as the LUA side will always use the same data type, there shouldn’t be any difference, as the same data type will be converted to text in the same way every time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a Java application that uses Kahlua for embedded Lua scripting. After calling
Lua has a really nice no-parenthesis call syntax that coupled with function closures allow
Part of a Lua application of mine is a search bar, and I'm trying
I built a Lua web application and it's become clear that I need to
I have a c++ application that interfaces with lua files. I have a lua
I've embedded Lua into my C application, and am trying to figure out why
I'll be quick: I have a C++ application that embeds Lua. Until now I
I am building a C++ application that embeds the Lua scripting engine. I am
I've been trying to embed lua in a c++ application but to no avail
I have trouble getting Application Data in Lua. I can't even find how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.