Victopia / php-node

Easy data framework for PHP MySQL, same query method for both physical and virtual columns.
Do What The F*ck You Want To Public License
1 stars 0 forks source link

Node::get() needs separation between AND and OR filtering. #5

Open vicary opened 11 years ago

vicary commented 11 years ago

Currently plain values in the filter is basically AND filtered, while arrays are OR filtered, consider the following code:

Node::get(array(
  '@collection' => 'foo'
, 'name' => 'pre%'
, 'type' => array('a','b')
));

This basically selects everything in the foo collection, with their name field starts with "pre", and their type field either equals to "a" OR "b".

This way is not very clear, needs to better separate between AND and OR.

The array OR method will be kept as a shorthand, while the real OR way is giving multiple arrays as the filter.

// The basic OR method will be like this.
Node::get(array(
  array(
    '@collection' => 'foo'
  , 'type' => 'a'
  )
, array(
    '@collection' => 'foo'
  , 'type' => 'b'
  )
));
vicary commented 9 years ago

Logical groups AND and OR should be made so that it is meaningful in nesting levels, as well as the root level of the specified $filter array for Node::get().

vicary commented 9 years ago

Taking reference to other model frameworks like Magento and ShopNC, something like array( 'eq' => $value ) would be viable and intuitive to use.

vicary commented 9 years ago

I am starting to love the BDD style totally chainable interfaces.

May rework this into something like this, while totally separates the Database dependency.

$data = Node($collection)
  ->filter($filter)
  ->map()
  ->filter($more_filter)
  ->get();