如何在yii框架中发布和获取两个表中的值?

时间:2014-04-18 08:55:41

标签: php yii

i从单个发布值并从表中获取它工作正常。如果从两个表发布并从两个表获取不显示第二个表数据。我叫var_dump($ aaa)。但它显示字符串"",

我在这里显示我的控制器代码。请建议如何改变云:

我确实喜欢这个。输出显示为字符串(0)""

 $model=new Recipe;   $model1= new Ingredienttype;
if(isset($_POST['Recipe']))
{
$model->attributes=$_POST['Recipe'];
 $recipe_name=$model->name;
 $course=$model->course_id;
$cuisine=$model->cuisinename;
 $type=$model->type;
 $calorie=$model->calorie_count;
 if(isset($_POST['Ingredienttype']))
$model1->attributes=$_POST['Ingredienttype'];
$ingredient=$model1->ingredient_type;
 var_dump($ingredient);
{

$this->redirect(array('advancesearch1','name'=>$recipe_name,
    'course'=>$course,'cuisine'=>$cuisine,'ingredient'=>$ingredient,
         'type'=>$type,'calorie'=>$calorie
        ));
    }

}

  $this->render('newadv',array('model'=>$model,'model1'=>$model1));

}

public function actionAdvancesearch1()
    {
       $model=new Recipe;

       $name=$_GET['name'];
       $course1=$_GET['course'];
       $cuisine1=$_GET['cuisine'];
       $type1=$_GET['type'];
       $calorie1=$_GET['calorie'];
       $ingredient1=$_GET['ingredient'];
       var_dump($ingredient1);

1 个答案:

答案 0 :(得分:1)

检查下一步:

  1. 的var_dump($ _ POST [' Ingredienttype'])
  2. ingredient_type是安全属性