Author Topic: pg_update record to NULL?  (Read 1503 times)

0 Members and 1 Guest are viewing this topic.

Offline zenlordTopic starter

  • Enthusiast
  • Posts: 54
    • View Profile
pg_update record to NULL?
« on: February 22, 2010, 10:28:07 AM »
Hi,

For one of my functions, I need to remove a value from a table, so I thought about setting it to NULL:

	
function 
removeDosLoc($file){
	
	
// Remove the old location, if any
	
	
$res pg_query(CNX_DOS"SELECT id,file,category FROM dossiers_location WHERE file = '$file'");
	
	
$num pg_num_rows($res);
	
	
if  (
$num !== 0) {
	
	
	
$fields = array('file' => NULL);
	
	
	
$condition = array('file' => $file);
	
	
	
pg_update(CNX_DOS,"dossiers_location"$fields$condition) or die("removeDosLoc: failed");
	
	
	
}
	
	
}

But I always get the die()-error. I use the same function to set the value to $file, so the function should be working - all I can think of is the 'NULL' that is incorrect? Or not?

thanks!

/EDIT: oh, and BTW: I checked that $num equals 1, so it is not a problem of $num being > 1 (the column is set to UNIQUE, so it couldn't be that problem...)
« Last Edit: February 22, 2010, 10:30:03 AM by zenlord »

Offline btherl

  • Guru
  • Fanatic
  • *
  • Posts: 3,791
  • Gender: Male
  • Matt is the best!
    • View Profile
Re: pg_update record to NULL?
« Reply #1 on: February 22, 2010, 07:31:29 PM »
What does pg_last_error() tell you?
Your php questions answered at Flingbits

Offline zenlordTopic starter

  • Enthusiast
  • Posts: 54
    • View Profile
Re: pg_update record to NULL?
« Reply #2 on: February 23, 2010, 02:45:01 AM »
Hmmm,

added the pg_last_error(), ran it again and it worked. Don't know where I messed up yesterday.

thanks for your answer and making me try it again :)

Offline btherl

  • Guru
  • Fanatic
  • *
  • Posts: 3,791
  • Gender: Male
  • Matt is the best!
    • View Profile
Re: pg_update record to NULL?
« Reply #3 on: February 23, 2010, 10:09:37 PM »
:)
Your php questions answered at Flingbits