static public function buildSearchPattern(common_persistence_SqlPersistence $persistence, $pattern, $like = true)
    {
        $returnValue = '';
        
        // Take care of RDFS Literals!
        if ($pattern instanceof core_kernel_classes_Literal) {
            $pattern = $pattern->__toString();
        }
        
        switch (gettype($pattern)) {
            case 'object' :
                if ($pattern instanceof core_kernel_classes_Resource) {
                    $returnValue = '= ' . $persistence->quote($pattern->getUri());
                } else {
                    common_Logger::w('non ressource as search parameter: '. get_class($pattern), 'GENERIS');
                }
                break;
            
            default:
                $patternToken = $pattern;
                $wildcard = mb_strpos($patternToken, '*', 0, 'UTF-8') !== false;
                $object = trim(str_replace('*', '%', $patternToken));
                
                if ($like) {
                    if (!$wildcard && !preg_match("/^%/", $object)) {
                        $object = "%" . $object;
                    }
                    if (!$wildcard && !preg_match("/%$/", $object)) {
                        $object = $object . "%";
                    }
                    if (!$wildcard && $object === '%') {
                        $object = '%%';
                    }
                    $returnValue .= 'LIKE LOWER(' . $persistence->quote($object) . ')';
                } else {
                    $returnValue .= '= '. $persistence->quote($patternToken);
                }
                break;
        }
        
        return $returnValue;
    }
static public function buildSearchPattern(common_persistence_SqlPersistence $persistence, $pattern, $like = true)
    {
        $returnValue = '';
        
        // Take care of RDFS Literals!
        if ($pattern instanceof core_kernel_classes_Literal) {
            $pattern = $pattern->__toString();
        }
        
        switch (gettype($pattern)) {
            case 'object' :
                if ($pattern instanceof core_kernel_classes_Resource) {
                    $returnValue = '= ' . $persistence->quote($pattern->getUri());
                } else {
                    common_Logger::w('non ressource as search parameter: '. get_class($pattern), 'GENERIS');
                }
                break;
            
            default:
                $patternToken = $pattern;
                $wildcard = mb_strpos($patternToken, '*', 0, 'UTF-8') !== false;
                $object = trim(str_replace('*', '%', $patternToken));
                
                if ($like) {
                    if (!$wildcard && !preg_match("/^%/", $object)) {
                        $object = "%" . $object;
                    }
                    if (!$wildcard && !preg_match("/%$/", $object)) {
                        $object = $object . "%";
                    }
                    if (!$wildcard && $object === '%') {
                        $object = '%%';
                    }
                    $returnValue .= 'LIKE LOWER(' . $persistence->quote($object) . ')';
                } else {
                    $returnValue .= '= '. $persistence->quote($patternToken);
                }
                break;
        }
        
        return $returnValue;
    }
static public function buildSearchPattern ( common_persistence_SqlPersistence $ persistence , $ pattern , $ like = true ) { $ returnValue = '' ; // Take care of RDFS Literals! if ( $ pattern instanceof core_kernel_classes_Literal ) { $ pattern = $ pattern -> __toString ( ) ; } switch ( gettype ( $ pattern ) ) { case 'object' : if ( $ pattern instanceof core_kernel_classes_Resource ) { $ returnValue = '= ' . $ persistence -> quote ( $ pattern -> getUri ( ) ) ; } else { common_Logger :: w ( 'non ressource as search parameter: ' . get_class ( $ pattern ) , 'GENERIS' ) ; } break ; default : $ patternToken = $ pattern ; $ wildcard = mb_strpos ( $ patternToken , '*' , 0 , 'UTF-8' ) !== false ; $ object = trim ( str_replace ( '*' , '%' , $ patternToken ) ) ; if ( $ like ) { if ( ! $ wildcard && ! preg_match ( "/^%/" , $ object ) ) { $ object = "%" . $ object ; } if ( ! $ wildcard && ! preg_match ( "/%$/" , $ object ) ) { $ object = $ object . "%" ; } if ( ! $ wildcard && $ object === '%' ) { $ object = '%%' ; } $ returnValue .= 'LIKE LOWER(' . $ persistence -> quote ( $ object ) . ')' ; } else { $ returnValue .= '= ' . $ persistence -> quote ( $ patternToken ) ; } break ; } return $ returnValue ; }
Build a SQL search pattern on basis of a pattern and a comparison mode.

@param  tring pattern A value to compare.
@param  boolean like The manner to compare values. If set to true, the LIKE SQL operator will be used. If set to false, the = (equal) SQL operator will be used.
@return string
Build a SQL search pattern on basis of a pattern and a comparison mode .