Browse Source

add NOT IN filter

Maurits van der Schee 9 years ago
parent
commit
cac80a1ace
2 changed files with 8 additions and 0 deletions
  1. 1
    0
      api.php
  2. 7
    0
      tests/tests.php

+ 1
- 0
api.php View File

@@ -772,6 +772,7 @@ class PHP_CRUD_API {
772 772
 			case 'ge': $comparator = '>='; break;
773 773
 			case 'gt': $comparator = '>'; break;
774 774
 			case 'in': $comparator = 'IN'; $value = explode(',',$value); break;
775
+			case 'ni': $comparator = 'NOT IN'; $value = explode(',',$value); break;
775 776
 			case 'is': $comparator = 'IS'; $value = null; break;
776 777
 			case 'no': $comparator = 'IS NOT'; $value = null; break;
777 778
 		}

+ 7
- 0
tests/tests.php View File

@@ -482,4 +482,11 @@ class PHP_CRUD_API_Test extends PHPUnit_Framework_TestCase
482 482
 		$test->expect('{"categories":[]}');
483 483
 	}
484 484
 
485
+	public function testFilterPostsNotIn()
486
+	{
487
+		$test = new API($this);
488
+		$test->get('/posts?filter[]=id,ni,1,2,3,4,7,8,9,10,11,12,13,14&transform=1');
489
+		$test->expect('{"posts":[{"id":"5","user_id":"1","category_id":"1","content":"#1"},{"id":"6","user_id":"1","category_id":"1","content":"#2"}]}');
490
+	}
491
+
485 492
 }

Loading…
Cancel
Save