Which of the lines are line 38?

On Apr 2, 8:43 pm, rossjha <[email protected]> wrote:
> Thanks for getting back to me, see below
>
> Notice (8): Undefined index:  status [APP\models\improvement.php, line
> 38]
>
>         function index() {
>                 $user_id = $this->Auth->user('id');
>                 $conditions = array(
>                         'conditions' => array('Improvement.user_id' => 
> $user_id),
>                         'fields' => array('Improvement.id', 
> 'Improvement.user_id',
> 'Improvement.title', 'Improvement.description', 'Improvement.status',
> 'Improvement.created')
>                 );
>                 $this->set('user_improvements', 
> $this->Improvement->find('all',
> $conditions));
>         }
>
> On Apr 2, 4:54 pm, brian <[email protected]> wrote:
>
> > What, specifically, is the error? And how are you fetching the results
> > from the DB?
>
> > On Thu, Apr 2, 2009 at 10:13 AM, [email protected]
>
> > <[email protected]> wrote:
>
> > > Hi
>
> > > Using afterFind to format $results, but i'm getting an Undefined index
> > > notice which is annoying!  How can i make sure the array has the
> > > appropriate index values?  Should i be doing something in my model
> > > relationships?
>
> > > Improvement model
> > >        class Improvement extends AppModel{
> > >                var $belongsTo = array(
> > >                        'User' => array(
> > >                                'className'=>'User',
> > >                                'foreignKey'=>'user_id'
> > >                        )
> > >                );
> > >                var $hasMany = array(
> > >                        'Bookmark' => array(
> > >                        'className'=>'Bookmark',
> > >                        'conditions'=>'',
> > >                        'fields'=>'',
> > >                        'order'=>'',
> > >                        'dependent'=>true,
> > >                        'foreignKey'=>'improvement_id'
> > >                        ),
> > >                        'Comment' => array(
> > >                        'className'=>'Comment',
> > >                        'conditions'=>'',
> > >                        'fields'=>'',
> > >                        'order'=>'',
> > >                        'dependent'=>true,
> > >                        'foreignKey'=>'improvement_id'
> > >                        ),
> > >                        'Vote' => array(
> > >                        'className'=>'Bookmark',
> > >                        'conditions'=>'',
> > >                        'fields'=>'',
> > >                        'order'=>'',
> > >                        'dependent'=>true,
> > >                        'foreignKey'=>'improvement_id'
> > >                        )
> > >                );
>
> > >                function afterFind($results){
> > >                        foreach($results as $key => $val){
> > >                                if(array_key_exists('Improvement', $val)){
> > >                                        var_dump($results);
> > >                                        
> > > $results[$key]['Improvement']['status'] = $this->getStatus
> > > ($results[$key]['Improvement']['status']);
> > >                                }
> > >                        }
> > >                        return $results;
> > >                }
>
> > > $results:
> > > array
> > >  0 =>
> > >    array
> > >      'Improvement' =>
> > >        array
> > >          'id' => string '5' (length=1)
> > >          'user_id' => string '12' (length=2)
> > >          'title' => string 'dictum pharetra. Pel' (length=15)
> > >          'description' => string '<p>Lorem ipsum dolor sit amet,
> > > consectetur adipiscing elit. Aliquam sit amet lacus eget eros dictum
> > > pharetra. Pellentesque tristique malesuada diam. Duis lobortis diam.
> > > Mauris neque. Sed posuere, magna sit amet tristique dictum, nulla
> > > tortor condimentum lorem, nec vestibulum ligula massa non metus.
> > > Quisque condimentum blandit mauris. In hac habitasse platea dictumst.
> > > Pellentesque consectetur est ut odio. Curabitur ornare nulla sed
> > > ligula. Sed lobortis, nulla a gravida gravida, felis nulla volutpat
> > > massa, si'... (length=1225)
> > >          'status' => string '0' (length=1)
> > >          'flag' => null
> > >          'private' => string '0' (length=1)
> > >          'created' => string '2009-03-17 09:21:00' (length=19)
> > >          'modified' => string '2009-03-17 09:21:00' (length=19)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to