@@ -1696,39 +1696,69 @@ protected function getSQLCondition(Query $query, array &$binds): string
16961696
16971697 return "MATCH( {$ alias }. {$ attribute }) AGAINST (: {$ placeholder }_0 IN BOOLEAN MODE) " ;
16981698
1699+ case Query::TYPE_NOT_SEARCH :
1700+ $ binds [": {$ placeholder }_0 " ] = $ this ->getFulltextValue ($ query ->getValue ());
1701+
1702+ return "NOT (MATCH( {$ alias }. {$ attribute }) AGAINST (: {$ placeholder }_0 IN BOOLEAN MODE)) " ;
1703+
16991704 case Query::TYPE_BETWEEN :
17001705 $ binds [": {$ placeholder }_0 " ] = $ query ->getValues ()[0 ];
17011706 $ binds [": {$ placeholder }_1 " ] = $ query ->getValues ()[1 ];
17021707
17031708 return "{$ alias }. {$ attribute } BETWEEN : {$ placeholder }_0 AND : {$ placeholder }_1 " ;
17041709
1710+ case Query::TYPE_NOT_BETWEEN :
1711+ $ binds [": {$ placeholder }_0 " ] = $ query ->getValues ()[0 ];
1712+ $ binds [": {$ placeholder }_1 " ] = $ query ->getValues ()[1 ];
1713+
1714+ return "{$ alias }. {$ attribute } NOT BETWEEN : {$ placeholder }_0 AND : {$ placeholder }_1 " ;
1715+
17051716 case Query::TYPE_IS_NULL :
17061717 case Query::TYPE_IS_NOT_NULL :
17071718
17081719 return "{$ alias }. {$ attribute } {$ this ->getSQLOperator ($ query ->getMethod ())}" ;
17091720
17101721 case Query::TYPE_CONTAINS :
1722+ case Query::TYPE_NOT_CONTAINS :
17111723 if ($ this ->getSupportForJSONOverlaps () && $ query ->onArray ()) {
17121724 $ binds [": {$ placeholder }_0 " ] = json_encode ($ query ->getValues ());
1713- return "JSON_OVERLAPS( {$ alias }. {$ attribute }, : {$ placeholder }_0) " ;
1725+ $ isNot = $ query ->getMethod () === Query::TYPE_NOT_CONTAINS ;
1726+ return $ isNot
1727+ ? "NOT (JSON_OVERLAPS( {$ alias }. {$ attribute }, : {$ placeholder }_0)) "
1728+ : "JSON_OVERLAPS( {$ alias }. {$ attribute }, : {$ placeholder }_0) " ;
17141729 }
17151730
17161731 // no break! continue to default case
17171732 default :
17181733 $ conditions = [];
1734+ $ isNotQuery = in_array ($ query ->getMethod (), [
1735+ Query::TYPE_NOT_STARTS_WITH ,
1736+ Query::TYPE_NOT_ENDS_WITH ,
1737+ Query::TYPE_NOT_CONTAINS
1738+ ]);
1739+
17191740 foreach ($ query ->getValues () as $ key => $ value ) {
17201741 $ value = match ($ query ->getMethod ()) {
17211742 Query::TYPE_STARTS_WITH => $ this ->escapeWildcards ($ value ) . '% ' ,
1743+ Query::TYPE_NOT_STARTS_WITH => $ this ->escapeWildcards ($ value ) . '% ' ,
17221744 Query::TYPE_ENDS_WITH => '% ' . $ this ->escapeWildcards ($ value ),
1745+ Query::TYPE_NOT_ENDS_WITH => '% ' . $ this ->escapeWildcards ($ value ),
17231746 Query::TYPE_CONTAINS => $ query ->onArray () ? \json_encode ($ value ) : '% ' . $ this ->escapeWildcards ($ value ) . '% ' ,
1747+ Query::TYPE_NOT_CONTAINS => $ query ->onArray () ? \json_encode ($ value ) : '% ' . $ this ->escapeWildcards ($ value ) . '% ' ,
17241748 default => $ value
17251749 };
17261750
17271751 $ binds [": {$ placeholder }_ {$ key }" ] = $ value ;
1728- $ conditions [] = "{$ alias }. {$ attribute } {$ this ->getSQLOperator ($ query ->getMethod ())} : {$ placeholder }_ {$ key }" ;
1752+
1753+ if ($ isNotQuery ) {
1754+ $ conditions [] = "{$ alias }. {$ attribute } NOT {$ this ->getSQLOperator ($ query ->getMethod ())} : {$ placeholder }_ {$ key }" ;
1755+ } else {
1756+ $ conditions [] = "{$ alias }. {$ attribute } {$ this ->getSQLOperator ($ query ->getMethod ())} : {$ placeholder }_ {$ key }" ;
1757+ }
17291758 }
17301759
1731- return empty ($ conditions ) ? '' : '( ' . implode (' OR ' , $ conditions ) . ') ' ;
1760+ $ separator = $ isNotQuery ? ' AND ' : ' OR ' ;
1761+ return empty ($ conditions ) ? '' : '( ' . implode ($ separator , $ conditions ) . ') ' ;
17321762 }
17331763 }
17341764
@@ -1971,9 +2001,6 @@ public function getSupportForNumericCasting(): bool
19712001
19722002 public function getSupportForIndexArray (): bool
19732003 {
1974- /**
1975- * Disabled to be compatible with Mysql adapter
1976- */
1977- return false ;
2004+ return true ;
19782005 }
19792006}
0 commit comments