model/SLSUSERS.php
/**
     * Searches users with regexp against one of the allowed search fields.
     * Allowed fields can be found from $fields-array.
     *
     * @param string $Rex   regexp to match against
     * @param string $Field whose contents are searched
     * 
     * @return mixed False if nothing was found or an array of matched rows
     * */
Searches users with regexp against one of the allowed search fields.
Allowed fields can be found from $fields-array.

@param string $Rex   regexp to match against
@param string $Field whose contents are searched

@return mixed False if nothing was found or an array of matched rows
Searches users with regexp against one of the allowed search fields . Allowed fields can be found from $fields - array . @param string $Rex regexp to match against @param string $Field whose contents are searched @return mixed False if nothing was found or an array of matched rows
public function findWithRex(string $Rex, string $Field) 
    {
        $fields = array(
                    SLSUSERS::NIMI,
                    SLSUSERS::JÄSENNUMERO,
                    SLSUSERS::PUHELIN,
                    SLSUSERS::SÄHKÖPOSTI,
                    SLSUSERS::KÄYTTÄJÄTUNNUS,
                    \mosBase\Malli::LUOTU,
                    \mosBase\Malli::MUOKATTU
                );
        $match=false;
        foreach ($fields as $f) {
            if ($f==$Field) {
                $match=true;
            }
        }
        if ($match===false) {
            return false;
        }
        if ($Field==SLSUSERS::JÄSENNUMERO
            || $Field==\mosBase\Malli::LUOTU
            || $Field==\mosBase\Malli::MUOKATTU
        ) {
            $op = "=";
        } else {
            $op = "~*";
        }
        $s = "select * from kayttaja where $Field $op :rex;";
        $st = $this->pdoPrepare($s, $this->db);
        $d = array("rex"=>$Rex);
        $this->pdoExecute($st, $d);
        if ($st->rowCount()==0) {
            return false;
        }
        return $st->fetchAll();        
    }
public function findWithRex ( string $ Rex , string $ Field ) { $ fields = array ( SLSUSERS :: NIMI , SLSUSERS :: JÄSENNUMERO, SLSUSERS :: PUHELIN , SLSUSERS :: SÄHKÖPOSTI, SLSUSERS :: KÄYTTÄJÄTUNNUS, \ mosBase \ Malli :: LUOTU , \ mosBase \ Malli :: MUOKATTU ) ; $ match = false ; foreach ( $ fields as $ f ) { if ( $ f == $ Field ) { $ match = true ; } } if ( $ match === false ) { return false ; } if ( $ Field == SLSUSERS :: JÄSENNUMERO || $ Field == \ mosBase \ Malli :: LUOTU || $ Field == \ mosBase \ Malli :: MUOKATTU ) { $ op = " = " ; } else { $ op = " ~* " ; } $ s = " select * from kayttaja where  $ Field $ op  :rex; " ; $ st = $ this -> pdoPrepare ( $ s , $ this -> db ) ; $ d = array ( " rex " => $ Rex ) ; $ this -> pdoExecute ( $ st , $ d ) ; if ( $ st -> rowCount ( ) == 0 ) { return false ; } return $ st -> fetchAll ( ) ; }
Searches users with regexp against one of the allowed search fields.
Searches users with regexp against one of the allowed search fields .