Advertisement:

Author Topic: The length of string parameters  (Read 309 times)

Offline AdamDevis

  • Newbie
  • *
  • Posts: 3
The length of string parameters
« on: June 14, 2018, 09:24:13 AM »
I noticed that when using $smcFunc['db_insert'] there is an option of restricting the length of string parameters (eg string-255). But that option isn't available when using $smcFunc['db_query']. And then I did a little digging and found that db_insert cuts the string to size and then re-labels it as just 'string' before sending the query off to db_query, at least for mysql anyway.

So I guess I'm just curious as to why the option to limit the length isn't there when using db_query. I'm sorry if there's something obvious about this which I've missed.

Thanks in advance!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,771
    • StoryBB/StoryBB on GitHub
Re: The length of string parameters
« Reply #1 on: June 15, 2018, 06:39:41 AM »
Mostly because there hasn’t historically been much reason to bother. If you want to cut the string, do it with string slicing in the SQL itself.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.