Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: AdamDevis on June 14, 2018, 09:24:13 AM

Title: The length of string parameters
Post by: AdamDevis 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!
Title: Re: The length of string parameters
Post by: Arantor 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.