FirebirdSQL / php-firebird

Firebird PHP driver
Other
66 stars 15 forks source link

Boolean false in parameter #23

Closed jacobalberty closed 2 years ago

jacobalberty commented 2 years ago

I have a table with a field that is the native firebird bool type. If I run a query like "update table set boolfield = false" it works fine, but I can't seem to run the following code

$stmt   = "update CLIENT_EMAIL set SEND_REMINDERS = ? where ID = ?";
$dbh = ibase_connect($host, $username, $password);

$hnd = ibase_query($dbh, $stmt, false, 4);

sending true updates but sending false gives me Warning: ibase_query(): Dynamic SQL Error SQL error code = -303 conversion error from string "" in /usr/share/nginx/html/test2.php on line 10

if i put a 0 there it does not error, but it doesn't update the value either.

jacobalberty commented 2 years ago

For now I am working around this by changing $stmt to resemble this $stmt = "update CLIENT_EMAIL set SEND_REMINDERS = iif(? = '1', true, false) where ID = ?";

That gets it behaving as expected on the php side, but it would be nice to not require hacks in the sql code to get the php code to behave correctly

haanerg commented 2 years ago

I'm pretty sure adding pings would work $hnd = ibase_query($dbh, $stmt, 'false', 4);

jacobalberty commented 2 years ago

adding single quotes around false results in the following error Warning: ibase_query(): Dynamic SQL Error SQL error code = -303 conversion error from string "e" in /usr/share/nginx/html/test2.php on line 11

code now looks like

$stmt   = "update CLIENT_EMAIL set SEND_REMINDERS = ? where ID = ?";
$dbh = ibase_connect($host, $username, $password);

$hnd = ibase_query($dbh, $stmt, 'false', 4);
haanerg commented 2 years ago

Weird, I just tested with PHP7.4.3 and version 1.1.0 of the driver and it worked there.

In other words, there's something to look into

jacobalberty commented 2 years ago

I'm using php 7.4.23 with version 1.1.1 of the driver running on the 4.0 release of firebird and the ddl for the table im testing with looks like this:

CREATE TABLE CLIENT_EMAIL
(
  ID integer NOT NULL,
  CLIENTID integer NOT NULL,
  "TYPE" varchar(32),
  ADDRESS varchar(256),
  SEND_REMINDERS boolean DEFAULT false NOT NULL,
  CONSTRAINT INTEG_70 PRIMARY KEY (ID)
);

I'm rebuilding with the older 1.1.0 version of the driver now to test, maybe its a regression in 1.1.1, it does look like the code was changed between the two.

jacobalberty commented 2 years ago

No luck with 1.1.0 either for me.

MartinKoeditz commented 2 years ago

What OS do you use? Please specify platform and bitness.

jacobalberty commented 2 years ago

output of uname -a is Linux sannhet 5.10.0-8-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03) x86_64 GNU/Linux

It's debian 11.0 I'm using docker with the base image of of php:7.4-fpm and I'm using the following dockerfile entry to build and install php-firebird

RUN CURDIR=$(pwd) && \
    TMPDIR=$(mktemp -d) && \
    apt-get -q update && \
    apt-get install -qy libtommath1 libncurses6 && \
    curl -L "https://github.com/FirebirdSQL/firebird/releases/download/v4.0.0/Firebird-4.0.0.2496-0.amd64.tar.gz" |  \
        tar -xz --strip 1 -C ${TMPDIR} && \
    cd ${TMPDIR} && \
    ./install.sh -silent && \
    /etc/init.d/firebird stop && \
    cd ${CURDIR} && \
    mkdir -p /usr/src/php/ext/php-firebird && \
    curl -L "https://github.com/FirebirdSQL/php-firebird/tarball/v1.1.1" |  \
    tar -xz --strip 1 -C /usr/src/php/ext/php-firebird && \
    docker-php-ext-install php-firebird && \
    apt-get purge --auto-remove -qy -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false libncurses6 && \
    apt-get -q clean && \
    rm -rf /var/lib/apt/lists/*

I've also tested with the distro default firebird libraries (3.0.7)

diegosardina commented 2 years ago

Same problem here, PHP 8.1.2, php-firebird 1.1.1 and Firebird 4.0.1