vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   fetch_foruminfo converts string to float (https://vborg.vbsupport.ru/showthread.php?t=298898)

TiKu 06-09-2013 09:13 AM

fetch_foruminfo converts string to float
 
Hi,

I've added a custom field 'ivw_code' to the 'forum' table. It is of type VARCHAR(25). If I call 'fetch_foruminfo' for a forum which has set this field to '12E03611', the returned array will contain the field as float(INF) instead of a string. This does not happen if I tell fetch_foruminfo to not use the cache, but read from the database.
So VB somewhere tries to be smart and converts the string to a float because of the 'E' in it. How can I avoid this?

Regards
TiKu

kh99 06-09-2013 11:24 AM

The code that builds the forumcache contains this (as part of a loop through the columns):
Code:

/* values which begin with 0 and are greater than 1 character are strings, since 01 would be an octal number in PHP */
if (is_numeric($val) AND !(substr($val, 0, 1) == '0' AND strlen($val) > 1) AND !in_array($key, array('title', 'title_clean', 'description', 'description_clean')))
{
        $newforum["$key"] += 0;
}


which (for some reason) forces a numeric type on fields that represent numbers. So I guess you would either need to store something that's not a number (like add a prefix to your code values), or if that doesn't work for you you could change that code (like adding 'ivw_code' to the array of column names in the code shown above).

TiKu 06-09-2013 01:12 PM

I don't want to edit VB files as this makes updates a pain. So now I'm prepending a character. It's an ugly hack, but it works. Thank you.


All times are GMT. The time now is 04:25 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01009 seconds
  • Memory Usage 1,709KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete