Yii Framework Forum: save() - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

save() Rate Topic: -----

#21 User is offline   viter 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 177
  • Joined: 21-January 10
  • Location:Ukraine Ivano-Frankivsk

Posted 05 February 2010 - 11:25 AM

View PostPoL, on 05 February 2010 - 09:27 AM, said:

But if it is an ajax call then the redirect redirects (sorry for the redundancy) that ajax call!!!
You need another approach to redirect the page that fires the ajax call (call it pageA), like return some value from the ajax call and then use javascript in pageA to do the redirect...


Ok, PoL thank you for your help and hints. I'll try to remake my code.
0

#22 User is offline   mvpind 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 17-December 09

Posted 17 February 2010 - 07:42 AM

View Postviter, on 05 February 2010 - 06:42 AM, said:

Hello everyone.

I have a piece of code:

if($misto->save())
{
        $m = $misto->misto;
	$o = $misto->oblid;
	$mc = new CDbCriteria;
	$mc->condition = "misto LIKE :sterm and oblid like :oblid";
	$mc->params = array(":sterm"=>"$m",":oblid"=>"$o");
	$mid = Mista::model()->find($mc);		
	$this->redirect(array('site/town','mid'=>$mid,'oblid'=>$misto->oblid));
}
else
{
	echo "record is not saved";
}


My problem is: the code that follows
if($misto->save())
is not run.



answer is

//if($misto->save())
if(isset($_post['Mista']))
{
$m = $misto->misto;
$o = $misto->oblid;
$mc = new CDbCriteria;
$mc->condition = "misto LIKE :sterm and oblid like :oblid";
$mc->params = array(":sterm"=>"$m",":oblid"=>"$o");
$mid = Mista::model()->find($mc);
$this->redirect(array('site/town','mid'=>$mid,'oblid'=>$misto->oblid));
}
else
{
echo "record is not saved";
}


Can anyone tell me why?
Thank you.

0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • 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