cancel
Showing results for 
Search instead for 
Did you mean: 

PHP MaxDb Extension, selecting float value

Former Member
0 Kudos

Operating system: CentOS 5.3 Final

PHP: 5.2.10

Apache: 1.3.41

MaxDB: 7.7 Linux 32 Bit

PHP MaxDb Extension: 7.6.00.38

Hi!

I have a table with a float field. But when I'm trying to select it via php, I'm getting an integer.

if($result = maxdb_query ($p_db, "select height from office_rent where id=75787"))	{
if($row = maxdb_fetch_row ($result))	
	$height	= $row[0];

maxdb_free_result ($result);
}
print_r($row);

The result is Array ( [0] => 3 ) although the "height " field contains 3.3.

May be it's some php.ini setting issue? Where am I wrong?

Thanks in advance,

Alex.

Edited by: Alex Petrov on Dec 18, 2009 6:33 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

simon_matter
Participant
0 Kudos

>

> Operating system: CentOS 5.3 Final

> PHP: 5.2.10

> Apache: 1.3.41

> MaxDB: 7.7 Linux 32 Bit

> PHP MaxDb Extension: 7.6.00.38

>

> Hi!

> I have a table with a float field. But when I'm trying to select it via php, I'm getting an integer.

>

>

if($result = maxdb_query ($p_db, "select height from office_rent where id=75787"))	{
> if($row = maxdb_fetch_row ($result))	
> 	$height	= $row[0];
> 
> maxdb_free_result ($result);
> }
> print_r($row);

>

> The result is Array ( [0] => 3 ) although the "height " field contains 3.3.

> May be it's some php.ini setting issue? Where am I wrong?

Hi Alex,

Unfortunately I don't have an idea what is wrong in your case. But what I know is that I also found bugs in the php maxdb extension and it may well be that you have found a bug too. Maybe it's just a question of different types of float, maybe the types you use does not map between maxdb and php. Just a wild guess because I'm far from being en expert on this.

I have put the patches I'm using in my rpms here [PHP MaxDB patches|http://www.invoca.ch/pub/packages/maxdb/] they are from the bugtracker at pecl.php.net and maxdb-7.6.00.38-php_assoc.patch is the one I created after I found a bug.

I don't really think one of those patches will help in your case but you may want to try it anyways.

BTW, the link will only be valid today.

Regards,

Simon

Former Member
0 Kudos

Thanks, Simon!

But I still have no solution to this bug.

It seems like moving from ODBC to MaxDB Php extension was pretty bad solution

simon_matter
Participant
0 Kudos

If you use var_dump instead of print_r, what type has the value returned? Is "height" really float in your db?

Edited by: Simon Matter on Jan 11, 2010 12:07 PM

Former Member
0 Kudos

var_dump shows

array(1) { [0]=> float(3) } 

and the "height" field is definitely float. Here is a screenshot from SQL Studio:

Link: [http://img15.imageshack.us/img15/1626/testro.jpg]

Same thing with other float fields - they just became integers in php

Edited by: Alex Petrov on Jan 11, 2010 12:23 PM

simon_matter
Participant
0 Kudos

Hm, that's interesting. I see that you use CentOS 5.3 but your apache and PHP are not the ones delivered with the OS.

Using CentOS 5.4 with it's php-5.1.6 I have just tried this and float values are fetched as float in my PHP.

for example I see

[3]=> float(7.3523502)

I have no idea why this doesn't work in your environment.

Former Member
0 Kudos

Thanks, Simon!

I tried to build it with latest php 5.3, but it was not compilable at all with "--with-maxdb" option.

Unfortunately, this is a production server, but I'll try to downgrade php this weekend. Hope it helps.