Re: PHP ODBC odbc_fetch_array returns uninitialized values for Booleans

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is it a truly a three state field (true, false, null) or just T/F? Perhaps
a default value for the field might be better?

On Mon, Jun 29, 2015 at 11:42 AM Bruce Bailey <brucebailey320@xxxxxxxxx>
wrote:

> *Description*
>
> The PHP function odbc_fetch_array returns uninitialized values for
> PostgreSQL boolean values.  On older systems, this function returned '1'
> for true and '0' for false values.  On our 64 bit system, the boolean
> values appear to be uninitialized data.
>
> *Additional information*
>
> Increasing buffer size in php_odbc.c (odbc.so) in function odbc_bindcols,
> just prior to call to SQLBindCol makes problem stop exhibiting.
>
> SQLColAttributes(...,SQL_COLUMN_TYPE,...) returns type of SQL_VARCHAR on
> system with problem, SQL_CHAR on system where code works as expected.
>
> SQLColAttributes is deprecated (shouldn't matter, though)
>
> *Recreation steps:*
>
> // Create table/data in PostgreSQL
>
> DROP TABLE IF EXISTS public.persons;
> create table public.persons (id int, name varchar(255), switch_sw boolean);
> insert into public.persons values (0, 'smith', true);
> insert into public.persons values (1, 'jones', false);
> insert into public.persons values (2, 'bailey', true);
> insert into public.persons values (3, 'johnson', false);
>
> // Test script
> <?php
>
>    if(!($conn = odbc_connect("..." , "..." , "...")))
>       die("odbc_connect failed\n");
>
>    if(!($rows = odbc_exec($conn, "select * from persons;")))
>       die("odbc_exec failed\n");
>
>    for(;;)
>    {
>       if (!($row = odbc_fetch_array ($rows)))
>          break;
>
>       print_r($row);
>    }
>
>    odbc_close($conn);
> ?>
>
> *Actual output*
>
> Array
> (
>     [id] => 0
>     [name] => smith
>     [switch_sw] => . // some unreadable binary content
> )
> . . .
>
> *Expected Output*
>
> Array
> (
>     [id] => 0
>     [name] => smith
>     [switch_sw] => 1
> )
> . . .
>
> *Software levels*
>
> kernel - Linux C921189 3.10.0-123.20.1.el7.x86_64 . . . GNU/Linux
> ODBC - libodbc.so.1 (cannot exactly determine version)
> PostgreSQL - 9.3.0
> PHP - 5.6.7
>
> This system is little endian
>

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux