FuelPHP CRUD – Orm find all where with or & and criteria

FuelPHP orm find all criteria with WHERE OR & AND is easy to achieve is we understand the concept behind and built the correct array.
The documentation stated as below without multiple criteria such as ‘WHERE (status = “single” OR status = “married”) AND name = “superman” ‘

// find all articles from category 1 or category 2
$entry = Model_Article::find('all', array(
    'where' => array(
        array('category_id', 1),
        'or' => array(
            array('category_id', 2),
        ),
    ),
));

My success example is as below:

$scope[] = array('status', 'single');
$scope['or'] = array('status', 'married');
$scope_and = array('name', '=', 'superman');
$data['user'] = \Model_User::find('all', array(
			'where' => array($scope, $scope_and), 
			'order_by' => array('created_at' => 'desc')
			)
		);

By Keenlio, March 12, 2014

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *


8 + = fourteen

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>