Avatar of Robert Granlund
Robert Granlund
Flag for United States of America asked on

PHP Code ignitor

I'm trying to write a query in CodeIgnitor and am a little stuck.

What I want to do is set up a variable.  The variable is either equal to $_GET['var']  or it is equal to anything

So when the query runs it will either thry to match the var in that field or it will return anything from that field if it has an entry or if it is empty.

	if (!empty($_GET['interface'])) {
		$interface = $_GET['interface'];
	} else {
		$interface = ' NULL OR NOT NULL';
	}

$query ->
-> from('exp_channel_data t1') 
	-> where('t1.entry_id', $related_id)
	-> where('t1.field_id_4911', $interface) 

Open in new window

PHPAJAXMySQL ServerWeb Frameworks

Avatar of undefined
Last Comment
Chris Stanyon

8/22/2022 - Mon
Dave Baldwin

So what's the problem?
Robert Granlund

ASKER
Can I write it that way?
$interface = ' NULL OR NOT NULL';
Dave Baldwin

I have no idea.  ' NULL OR NOT NULL' should match everything so it doesn't mean anything.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER CERTIFIED SOLUTION
Chris Stanyon

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.