Monday, October 4, 2010

Re: find with null

yep, thats because NULL is not an appropriate value to work with
you should have used NOT NULL for your fields and test on empty
strings ('field'=>'') in the first place


On 4 Okt., 13:42, lyba <l...@poczta.fm> wrote:
> THE ABOVE PROBLEM IS SOLVED (my second post).
>
> THIS IS THE ONLY SOLUTION (so far) TO THE ABOVE PROBLEM.
>
> I believe the solution is not too bad, despite being slightly off to
> the cake conventions.
> To overcome the problem pointed here a find-function-developer would
> need to rewrite its work to take into consideration a special meaning
> of null as not being treated a standard SQL value - cannot be part of
> IN SQL statement.
>
> Neither of the following will work:
>
> 'OR'=> array('title IS'=>null, 'title'=>$TitleArray)
> - cake produces: SQL: (`title ` IS = NULL)  - DB will not show null
> values if requested in this way (tested MySQL)
>
> $TitleArray = array('a', 'b', 'c', null);
> - SQL does not interpret null in this (tested MySQL) - DB will not
> show records with null value, will show others
>
> 'conditions' => array('title'=>null, 'OR' => array('title'=>
> $TitleArray))
> - cake produces SQL: `title` IS NULL AND title = (1) - this will not
> show any values as both are contradicting each other (default AND
> between statements, for OR values should be inside OR array

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: