Yii Framework Forum: Model->Save() Methodu Problemi - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Model->Save() Methodu Problemi

#1 User is offline   selo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 52
  • Joined: 08-November 13

Posted 15 January 2014 - 12:15 PM

Merhaba

ajaxdan aldıgım mesela 5 datayı kaydetmek istiyorum.ama 1.den sonra diğerlerini save etmiyor.Nasıl yapmak lazım.for un içi dönüyor.

foreach($autoIdAll as $autoId)
                    {
                        $frnd = $friends->model()->findByAttributes(array("name" => $name, 'friend_id'=>$autoId));
                        if($frnd == NULL ) {
                            $friends->attributes = array('name' => $name, 'friend_id' => $autoId, 'request' => 1);
                            $friends->save();
                            $friends->unsetAttributes();
                        }
                    }

0

#2 User is offline   McQueen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 138
  • Joined: 13-August 11
  • Location:Istanbul/Turkey

Posted 15 January 2014 - 12:56 PM

View Postselo, on 15 January 2014 - 12:15 PM, said:

Merhaba

ajaxdan aldıgım mesela 5 datayı kaydetmek istiyorum.ama 1.den sonra diğerlerini save etmiyor.Nasıl yapmak lazım.for un içi dönüyor.

foreach($autoIdAll as $autoId)
                    {
                        $frnd = $friends->model()->findByAttributes(array("name" => $name, 'friend_id'=>$autoId));
                        if($frnd == NULL ) {
                            $friends->attributes = array('name' => $name, 'friend_id' => $autoId, 'request' => 1);
                            $friends->save();
                            $friends->unsetAttributes();
                        }
                    }



Bir denermisin?
foreach($autoIdAll as $autoId)
                    {
                        $frnd = $friends->model()->findByAttributes(array("name" => $name, 'friend_id'=>$autoId));
                        if($frnd == NULL ) {
                            $friends = new Friends();
                            $friends->attributes = array('name' => $name, 'friend_id' => $autoId, 'request' => 1);
                            $friends->save();
                            unset($friends);
                        }
                    }

0

#3 User is offline   selo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 52
  • Joined: 08-November 13

Posted 17 January 2014 - 09:09 AM

problemi çözdü ama create işlemi için her defasında yeni yaratmak olmamalı.
0

#4 User is offline   McQueen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 138
  • Joined: 13-August 11
  • Location:Istanbul/Turkey

Posted 17 January 2014 - 09:32 AM

View Postselo, on 17 January 2014 - 09:09 AM, said:

problemi çözdü ama create işlemi için her defasında yeni yaratmak olmamalı.


Bence yeniden create etmelisin. başka türlü set edemezsin.
0

#5 User is offline   selo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 52
  • Joined: 08-November 13

Posted 18 January 2014 - 02:05 PM

hayır save edince 3 kere return 1 alıyorsun bi de :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users