function uniqueCode()
    {
        $i = 1;
        $codeFormat = 'code-%d';
        do {
            $code = sprintf($codeFormat, $i);
            $note = $this->findByCode($code);
            if (!$note) {
                return $code;
            }
            $i++;
        } while (true);
    }
function uniqueCode()
    {
        $i = 1;
        $codeFormat = 'code-%d';
        do {
            $code = sprintf($codeFormat, $i);
            $note = $this->findByCode($code);
            if (!$note) {
                return $code;
            }
            $i++;
        } while (true);
    }
function uniqueCode ( ) { $ i = 1 ; $ codeFormat = 'code-%d' ; do { $ code = sprintf ( $ codeFormat , $ i ) ; $ note = $ this -> findByCode ( $ code ) ; if ( ! $ note ) { return $ code ; } $ i ++ ; } while ( true ) ; }
Generates a unique code along these formats "code-1", "code-2" to be used for inserting a new note
Generates a unique code along these formats code - 1 code - 2 to be used for inserting a new note