Welcome Guest, Not a member yet? Register   Sign In
Why would CI change the type of my data from int to string ?
#1

[eluser]vincej[/eluser]
Hi - I have a very normal query which pulls a collection of Unix Time stamps ( Ints ) plus 2 strings ( varchars) out of my DB. I have used this form of query 100 times. I deliver e results back to my view via the controller without doing anything to it's type, other than putting them into an array. By the time the time stamps get to the view they have become strings which then of coure gives me an error "A non well formed numeric value encountered" when I try to so a strfime().

I have checked the PHP manual and canot see if this is standard behaviour.

Is there a CI mechanism for keeping the type or should I just run settype($variable,"integer") to get them back ?

Many Thanks !

#2

[eluser]InsiteFX[/eluser]
Type Casting Variables
#3

[eluser]Aken[/eluser]
It is standard behavior - the MySQL driver uses functions like mysql_fetch_object() and mysql_fetch_assoc() to generate the result rows.

From mysql_fetch_object():

Quote:Return Value
Returns an object with string properties that correspond to the fetched row, or FALSE if there are no more rows.




Theme © iAndrew 2016 - Forum software by © MyBB