pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: scott.marlowe <scott.marlowe@ihs.com>
To: S.P.Vimala <vimala@ncb.ernet.in>
Cc: pgsql-php@postgresql.org
Subject: Re:
Date: Tue, 16 Sep 2003 07:11:36 -0600 (MDT)
Message-ID: <Pine.LNX.4.33.0309160704200.4036-100000@css120.ihs.com> (raw)
In-Reply-To: <Pine.LNX.4.33.0309160950360.24227-100000@trinetra.ncb.ernet.in>

Sure, you just need a constraint:

create table test (info text constraint "no blanks" check (info<>'' and info<>' ') not null);
CREATE TABLE
insert into test (info) values ('');
ERROR:  new row for relation "test" violates CHECK constraint "no blanks"

I'm not sure how to add constraints to already existing tables, so you 
might wanna do this in a test table, move your data over, then rename 
tables to swap in the new table.

On Tue, 16 Sep 2003, S.P.Vimala wrote:

> 
> 
> I think u are right, My code goes like this.......
> 
> 
> This is what i do in my html page
> $result  =  insert_user($userloginid,$username,$password,$usertype,$txtAddress,
> $phoneno,$email);
> 
> The function insert_user is like this.
> 
> function insert_user($loginid,$username,$password,$usertype,$txtAddress,$phoneno,$email){
>      if($dbhandle=get_dbconnection())
>       {
> 		$query="insert into vyapar_user values('". $loginid .
> "','" . $username . "','" . $password . "','" . $usertype . "','" .
> $txtAddress . "','" . $phoneno . "','" . $email .  "')";
> 		$result=pg_exec($dbhandle,$query);
> 		if(!result)
> 		   return null;
> 		else
> 		   return $result;
>       }
> }
> 
> 
> I need to prevent '' as well as ' ' entry into the db which are also null
> values may be not theoritically but in practice they are....
> 
> so any suggestions?
> 
> 
> 
> > On Mon, 15 Sep 2003, S.P.Vimala wrote:
> >
> > > Hi,
> > >
> > >          I have a table in postgresql db with the following description.
> > >
> > >                 - Table: vyapar_user
> > > CREATE TABLE vyapar_user (
> > >   loginid varchar(150) NOT NULL,
> > >   name varchar(150) NOT NULL,
> > >   "password" varchar(32) NOT NULL,
> > >   "type" varchar(10) NOT NULL,
> > >   address varchar(100) NOT NULL,
> > >   phone varchar(15),
> > >   email varchar(20),
> > >   creationdate date DEFAULT date('now'::text),
> > >   expriydate date DEFAULT (date('now'::text) + 360),
> > >   CONSTRAINT vyapar_user_pk PRIMARY KEY (loginid)
> > > ) WITH OIDS;
> > >
> > >
> > >         If i try inserting NULL values from backend, then it gives me an
> > > error. But  thru php, its adds null values without any errors. Any idea
> > > how to solve this issue.....
> >
> > I'll need to see some sample code.  In my experience, PHP cannot insert
> > NULLS into not null fields.
> >
> > Are you sure you're not inserting '' and thinking of it as NULL?  They're
> > not the same.
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 9: the planner will ignore your desire to choose an index scan if your
> >       joining column's datatypes do not match
> >
> 
> 




view thread (7+ messages)  latest in thread

Message-ID: <Pine.LNX.4.33.0309160704200.4036-100000@css120.ihs.com>
Permalink:  ../Pine.LNX.4.33.0309160704200.4036-100000@css120.ihs.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.33.0309160704200.4036-100000@css120.ihs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: scott.marlowe@ihs.com, vimala@ncb.ernet.in
  Subject: Re: 
  In-Reply-To: <Pine.LNX.4.33.0309160704200.4036-100000@css120.ihs.com>
  References: <Pine.LNX.4.33.0309160950360.24227-100000@trinetra.ncb.ernet.in> <Pine.LNX.4.33.0309160704200.4036-100000@css120.ihs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox