Link to home
Create AccountLog in
Avatar of Robert Granlund
Robert GranlundFlag 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

Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

So what's the problem?
Avatar of Robert Granlund


Can I write it that way?
$interface = ' NULL OR NOT NULL';
I have no idea.  ' NULL OR NOT NULL' should match everything so it doesn't mean anything.
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account