Jump to content

pg_update record to NULL?


zenlord

Recommended Posts

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...)

Link to comment
https://forums.phpfreaks.com/topic/192942-pg_update-record-to-null/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.