Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Relational Db Issues

$
0
0
Hi, I have a website with a Builder model. The idea is that the Builder creates multiple subcontractors under their profile and then has them displayed to interact with. I wrote the code below and can get the Subcontractor created through the Builder model, but no data is being generated to by JBuildSub table. My understanding is that I need to create pairs of builderID/subcontractorID in a joint table so that I can then draw back into my Builder model the unique subcontractors that apply to that specific Builder. I don't understand why this JBuildSub table won't take the data. It has only two columns in it of: builderId and subcontractorId.

I've read over and over all the documentation and tutorials I can find on the Yiiframework website so please don't refer back to one of those documents. I need further clarification on how to get this working properly.

Thanks so much for any help you can provide.

public function actionCreateSub()
{
$model=new Subcontractor;
$joint=new JBuildSub;

if(isset($_POST['Subcontractor']))
{
$model->attributes=$_POST['Subcontractor'];
$joint->subcontractorId = $model->id;
$joint->builderId = $this->id;
$joint->save();
if($model->save())
$this->redirect('subcontractors');
}

$this->render('create_sub',array(
'model'=>$model,
));
}

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>