How to revert back to something with conditions

I have a bunch of companies that has a status of 0 as default but sometimes get a higher status. Now i want to use the high status if exists but revert to 0 if not. i have tried a bunch of different approaches but i always get either only the ones with status 0 or the ones with the status i want, never giving me status if exists and 0 if not.

Gives me only the status i want:


'Company' => array (
	'conditions' =>  array (
		'OR' => array(
			'Company.status' => 0,
			'Company.status' => $status,
		)
		
	)
)

Gives me only status of 0:


'Company' => array (
	'conditions' =>  array (
		'OR' => array(
			'Company.status' => $status,
			'Company.status' => 0
		)
	)
)

Asked by eldamar, on 12/12/11

1 Answer

Try...


'Company' => array (
    'conditions' =>  array (
        'OR' => array(
            array('Company.status' => 0),
            array('Company.status' => $status),
        )
        
    )
)

Remember they're just PHP arrays. An array with duplicate keys will just use the last set one (as the key in an array is unique).

Answered by kylerobinsonyoungon 15/12/11

<< previous next >>

Your Answer

You can use Creole Wiki Syntax to format your text.

Rating

0

Viewed

367 times

Last Activity

on 15/12/11