Jump to content

pg_update record to NULL?


Recommended Posts



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?




/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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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