Subject Re: [firebird-support] Re: Weird php and firebird problem, repeating values
Author Fabio Gomes
The problem isnt the concept, is that the stupid php 5 mess up with my data
when i DONT set null, so i HAVE to use null or php keep repeating my data
when i export it into txt, and i need to export this data.

And i had to make a "gambiarra" as we call here in brazil, or a work around
as you may say...

To have null written in my database, i had to do this:

if i set:

$var = NULL;

It writes ' '

if i set:

$var = 'NULL';

it writes "NULL" as a string

So i have to do it:

$sql = "INSERT INTO table (field1, field2) VALUES ($var1, $var2)";

Then i did it:

$sql = str_replace("''", 'NULL', $sql);

notice the two single quotes inside the double quotes, so i replace the
empty vars on the query with NULL without quotes, there was the only way
that it worked.

You can say that its dirty, i found a lot of things talking about it in php,
but none worked, i tried to set some config values to write NULL as NULL and
not '', but nothing worked... so i made it my way.

But now its working, and thats what is important.

I just find all this thing messy, cause i spent 2 whole days of work to find
a work around for this problem.

But thanx a lot for all the support, it was really helpfull and i m learning
a lot about firebird.. its a brand new world for me :)

On 12/13/05, Adam <s3057043@...> wrote:
>
> --- In firebird-support@yahoogroups.com, Fabio Gomes <fabioxgn@g...>
> wrote:
> >
> > Sorry guys about bothering you again, but..
> >
> > I ve re-created my database and i used DEFAULT NULL to create the
> tables,
> > but it seens that it still leave the data "blank" on the field, is there
> > some way to write NULL in the field if i send a blank data? or i ll
> have to
> > change all my php code to send NULL instead of a empty data?
> >
> > Thanx.
>
> The default value is only used when you do not provide a value, and
> only during an insert operation.
>
> create table t
> (
> a integer,
> b varchar(10) default null
> );
>
> commit;
>
> insert into table (a,b) values (1, '');
> insert into table (a) values (2);
> select * from t;
>
> a b
> == ==
> 1 ''
> 2 <null>
>
> You have to forget everything you may have learnt about null = 0 or
> null = empty string or null = some weird date.
>
> NULL is a concept, not a value. (A bit like infinity in that regard).
> NULL is synonymous with unknown, or undefined or not relevant.
>
> A simple example is a persons middle name.
>
> You may have a table of people, some have middle names that you know,
> some you know have no middle name, and the rest may or may not have a
> middle name.
>
> Those who you know do not have a middle name should be given '' as
> their middle name. But if you do not know their middle name or if they
> have one, then use null, see the difference. NULL is a flag on the
> fields value, not a value itself.
>
> Have a good read of this document and you will see how it works and
> will not be pulling out your hair over it.
>
> http://firebird.sourceforge.net/pdfmanual/Firebird-Null-Guide.pdf
>
> Adam
>
>
>
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
>
>
> SPONSORED LINKS
> Technical support<http://groups.yahoo.com/gads?t=ms&k=Technical+support&w1=Technical+support&w2=Computer+technical+support&w3=Compaq+computer+technical+support&w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=Microsoft+technical+support&c=6&s=196&.sig=-XIO8GxY6hqd3NaD5WSEyw> Computer
> technical support<http://groups.yahoo.com/gads?t=ms&k=Computer+technical+support&w1=Technical+support&w2=Computer+technical+support&w3=Compaq+computer+technical+support&w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=Microsoft+technical+support&c=6&s=196&.sig=B29J78SYXnNTjjMFBMznqA> Compaq
> computer technical support<http://groups.yahoo.com/gads?t=ms&k=Compaq+computer+technical+support&w1=Technical+support&w2=Computer+technical+support&w3=Compaq+computer+technical+support&w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=Microsoft+technical+support&c=6&s=196&.sig=7_je1A94xs82CFXUjEqA6g> Compaq
> technical support<http://groups.yahoo.com/gads?t=ms&k=Compaq+technical+support&w1=Technical+support&w2=Computer+technical+support&w3=Compaq+computer+technical+support&w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=Microsoft+technical+support&c=6&s=196&.sig=2zMAuRCo5cJrVBr1Bxa3_w> Hewlett
> packard technical support<http://groups.yahoo.com/gads?t=ms&k=Hewlett+packard+technical+support&w1=Technical+support&w2=Computer+technical+support&w3=Compaq+computer+technical+support&w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=Microsoft+technical+support&c=6&s=196&.sig=_ytYU7aXb57AVaeUfmvLcA> Microsoft
> technical support<http://groups.yahoo.com/gads?t=ms&k=Microsoft+technical+support&w1=Technical+support&w2=Computer+technical+support&w3=Compaq+computer+technical+support&w4=Compaq+technical+support&w5=Hewlett+packard+technical+support&w6=Microsoft+technical+support&c=6&s=196&.sig=4hRo6NXYavRAbTkaYec5Lw>
> ------------------------------
> YAHOO! GROUPS LINKS
>
>
> - Visit your group "firebird-support<http://groups.yahoo.com/group/firebird-support>"
> on the web.
>
> - To unsubscribe from this group, send an email to:
> firebird-support-unsubscribe@yahoogroups.com<firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe>
>
> - Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------
>


[Non-text portions of this message have been removed]