PHP: MySQL issues

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

PHP: MySQL issues

Elsass Philippe
Hello,

MySQL's bigint type is reported as int by mysql_field_type(), and thus
is converted using intval() which is obviously leads to conversion
issues - is there a way to disable the conversion?

Also, looking at the internal MysqlResultSet.class.php implementation
I see getFieldsDescription() is called for each row - is there a
reason why it isn't evaluated once and cached?

--
Philippe

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: PHP: MySQL issues

Krzysztof Różalski
Hi Philippe,

I had this problem when trying to store facebook uids as bigints in the database and strings in spod class. The only solution I've found is rather ugly:
I wrapped MysqlConnection with my  MysqlConnectionWrapper just to return a different result set
In the result set I check if  Std.string(convertedToIntValue) == convertedToStringValue and if not the returns string instead of int

Cheers!
Krzysztof

On Sun, Jul 10, 2011 at 12:33 AM, Elsass Philippe <[hidden email]> wrote:
Hello,

MySQL's bigint type is reported as int by mysql_field_type(), and thus
is converted using intval() which is obviously leads to conversion
issues - is there a way to disable the conversion?

Also, looking at the internal MysqlResultSet.class.php implementation
I see getFieldsDescription() is called for each row - is there a
reason why it isn't evaluated once and cached?

--
Philippe

--
haXe - an open source web programming language
http://haxe.org



--
blog.krozalski.com

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: PHP: MySQL issues

alexander.konotop
В Sun, 10 Jul 2011 08:34:48 +0200
Krzysztof Różalski <[hidden email]> пишет:

> Hi Philippe,
>
> I had this problem when trying to store facebook uids as bigints in
> the database and strings in spod class. The only solution I've found
> is rather ugly:
> I wrapped MysqlConnection with my  MysqlConnectionWrapper just to
> return a different result set
> http://code.google.com/p/hapi/source/browse/trunk/hapi/db/MysqlConnectionWrapper.hx
> In the result set I check if  Std.string(convertedToIntValue) ==
> convertedToStringValue and if not the returns string instead of int
> http://code.google.com/p/hapi/source/browse/trunk/hapi/db/MysqlHapiResultSet.hx
>
> Cheers!
> Krzysztof
>
> On Sun, Jul 10, 2011 at 12:33 AM, Elsass Philippe
> <[hidden email]
> > wrote:
>
> > Hello,
> >
> > MySQL's bigint type is reported as int by mysql_field_type(), and
> > thus is converted using intval() which is obviously leads to
> > conversion issues - is there a way to disable the conversion?
> >
> > Also, looking at the internal MysqlResultSet.class.php
> > implementation I see getFieldsDescription() is called for each row
> > - is there a reason why it isn't evaluated once and cached?
> >
> > --
> > Philippe
> >
> > --
> > haXe - an open source web programming language
> > http://haxe.org
> >
>
>
>

I also use Strings for bigint in neko + PostgreSQL. It was the
simpliest way.


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Re: PHP: MySQL issues

Elsass Philippe
In reply to this post by Elsass Philippe
Krzysztof,

I'm also trying to store Facebook IDs ;)

I eventually just made a copy of Mysql.hx and commented out the
conversion part - I prefer to handle it myself as needed.

PS: I was wrong about fields description - it's cached.

--
haXe - an open source web programming language
http://haxe.org