php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36069 AGAIN - mysql_field_type returns 'unknown' for DECIMAL columns in MySQL 5.0+
Submitted: 2006-01-18 16:48 UTC Modified: 2006-01-19 18:11 UTC
From: alcofora at netmake dot com dot br Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.1.2 OS: Windows
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: alcofora at netmake dot com dot br
New email:
PHP Version: OS:

 

 [2006-01-18 16:48 UTC] alcofora at netmake dot com dot br
Description:
------------
The same problem that happend with PHP 4.4.1 and was reported on ticket ID# 35536.

Its was solved for php 4.4.1 but is back again on php 4.4.2 the has been launched last day 13.

When we call 'mysql_field_type' for a decimal field it return as 'unknown'.

Please look this.

Reproduce code:
---------------
<?php
/*
CREATE TABLE `test` (
`fielda` int(11) NOT NULL,
`fieldb` decimal(10,3) default NULL,
PRIMARY KEY (`fielda`)
);	
*/


mysql_connect("localhost:3306", "root", "123");
mysql_select_db("test");
$result = mysql_query("SELECT * FROM test");
$fields = mysql_num_fields($result);
$rows = mysql_num_rows($result);
$table = mysql_field_table($result, 0);
echo "Your '" . $table . "' table has " . $fields . " fields and " . $rows . " record(s)\n";
echo "The table has the following fields:\n";
for ($i=0; $i < $fields; $i++) {
$type = mysql_field_type($result, $i);
$name = mysql_field_name($result, $i);
$len = mysql_field_len($result, $i);
$flags = mysql_field_flags($result, $i);
echo $type . " " . $name . " " . $len . " " . $flags . "\n";
}
mysql_free_result($result);
mysql_close();
?>

Expected result:
----------------
Your 'test' table has 2 fields and 0 record(s) The table has the following fields: int fielda 11 not_null primary_key real fieldb 12

Actual result:
--------------
Your 'test' table has 2 fields and 0 record(s) The table has the following fields: int fielda 11 not_null primary_key unknown fieldb 12 not_null

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-18 16:55 UTC] tony2001@php.net
1) There is no such OS - "Any".
2) With which version of libmysqlclient did you build PHP?
 [2006-01-18 17:26 UTC] alcofora at netmake dot com dot br
I'm testing on WINDOWS. I did'n tested on linux yet.


I'm using official php.net package.
 PHP 4.4.2
  MySQL Support	enabled
  Active Persistent Links 	0
  Active Links 	0
  Client API version 	3.23.49



I've tested now with PHP 5.1.2 too and also happend the same thing. Using official package and no changes.

 PHP 5.1.2
   MySQL Support	enabled
   Active Persistent Links 	0
   Active Links 	0
   Client API version 	4.1.7
 [2006-01-18 17:35 UTC] tony2001@php.net
PHP must be compiled with MySQL 5 to support field types that appeared first in MySQL 5.

 [2006-01-18 18:09 UTC] alcofora at netmake dot com dot br
Hi,

  I understant that, but i'm using WINDOWS binary package that comes from php.net. I don't compile anything WINDOWS.

  Shouldn't the binary official version come with the newest MySQL Client API, including support for ALL MySQL?

Thanks.
 [2006-01-18 18:20 UTC] tony2001@php.net
No, it shouldn't.
And we also do not distribute separate modules for all versions of Oracle, Interbase, Sybase, MSSQL, Postgresql, Ingres, DB2 etc.
 [2006-01-19 14:09 UTC] alcofora at netmake dot com dot br
Hi,

 Now i'm using PHP 5.1.2 and
    MySQL Support	enabled
    Active Persistent Links 	0
    Active Links 	0
    Client API version 	5.0.16

I'm using libmysql.dll that comes from MySQL5.

The problem with decimal still happening.
 [2006-01-19 14:22 UTC] tony2001@php.net
As I've said, PHP must be *compiled* with the version of MySQL where these types are available.
These types won't magically appear in php_mysql.dll just because you're using new libmysql.dll.
 [2006-01-19 18:11 UTC] georg@php.net
If you don't like to compile your php stuff, use the dll's for mysql/mysqli from the MySQL AB web site: http://dev.mysql.com/downloads/connector/php/





 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 12 09:01:27 2024 UTC