php findby - How to query NOT NULL with Doctrine?

equal (3)

I have table Test:

id | name 
1  | aaa
2  | 
3  | ccc
4  | aaa
5  | 
6  | ddd

I want result where name is NOT NULL:


How can i get with:

Doctrine_Core::getTable('Test')->findBy('name', NOTNULL??) <-doesnt working

and in model with:

     ->where('name = ?', NOTNULL ???) <- doesnt working


Do it in Doctrine way, from query builder and Expr class.

 $qb = $entityManager->createQueryBuilder();
 $result = $qb->select('t')

there are also distinct() function.

Try this:

     ->where('name IS NOT NULL')

which is standard SQL syntax. Doctrine doesn't convert Null values into proper sql.

I have to agree with Alan. If the existing regex is so complicated, why try and do it in just one regex?

Just break it down into approachable simple steps. You have already done that.

Now write 4 regex to validate your parts, add basic logic to the 4 regex and measure the length of the string. Done.

Which would you rather debug, this:

(?=^(?:[^A-Z]*[A-Z]){2})(?=^(?:[^a-z]*[a-z]){2})(?=^(?:\D*\d){2})(?=^(?:\w*\W){2})^[A-Za-z\d\W]{8,}$ (which does not work btw...)

or this:

function valid_pass($candidate) {
   $r1='/[A-Z]/';  //Uppercase
   $r2='/[a-z]/';  //lowercase
   $r3='/[[email protected]#$%^&*()\-_=+{};:,<.>]/';  // whatever you mean by 'special char'
   $r4='/[0-9]/';  //numbers

   if(preg_match_all($r1,$candidate, $o)<2) return FALSE;

   if(preg_match_all($r2,$candidate, $o)<2) return FALSE;

   if(preg_match_all($r3,$candidate, $o)<2) return FALSE;

   if(preg_match_all($r4,$candidate, $o)<2) return FALSE;

   if(strlen($candidate)<8) return FALSE;

   return TRUE;

Why folks feel they have to write a regex that no one can understand just so they can do it in one go is beyond me...

Ok ok -- if you really want a single regex, learn about lookaheads to validate your rules.

This monster does what you asked in one go:

^                                        # start of line
(?=(?:.*[A-Z]){2,})                      # 2 upper case letters
(?=(?:.*[a-z]){2,})                      # 2 lower case letters
(?=(?:.*\d){2,})                         # 2 digits
(?=(?:.*[[email protected]#$%^&*()\-_=+{};:,<.>]){2,})  # 2 special characters
(.{8,})                                  # length 8 or more
$                                        # EOL 


php symfony1 doctrine symfony-1.4 doctrine-1.2