Jump to content

mysql_fetch_****() question


kratsg

Recommended Posts

Just a quick question for anyone who knows:

 

Does mysql_fetch_*****() always return values from the database in the form of strings (regardless of what data type it is set in the database?)

 

The reason I ask is I did something like the following:

 

while($row = mysql_fetch_object($curr_data)){
var_dump($row);
//....
//....
}

 

Which outputted

 

object(stdClass)#1 (3) { ["pid"]=>  string(1) "1" ["description"]=>  string(35) "Allows user to view survey results." ["expires"]=>  string(1) "0" }

 

Now, 'pid' and 'expires' are both set as integers in the database. There's nothing wrong with the values, but rather the type of values they are.

 

~kratsg.

Link to comment
Share on other sites

From the documentation -

Return Values

Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows.

 

The data type of the php array elements are strings, even if the values are numbers or are defined as a numeric data type in the table.

 

Due to php's loose data typing and automatic type casting, this is usually NOT an issue. Do you have a specific problem?

 

Link to comment
Share on other sites

Hey,

 

I don't particularly have a problem. It was just interesting when I dumped the object to see exactly what happened with the stored values (since I did use a join) and I was wondering if the periods also carried over in the property names:

 

	$statement_paginate = "SELECT perms.pid, perms.description, user_perms.expires FROM perms, user_perms WHERE user_perms.fk_uid = '$user_id' AND perms.pid = user_perms.fk_pid ORDER BY perms.pid ASC";

 

They appear not to. No problem here.

 

Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.