title: Yii - Saving Data between 3 tables
body: <p>I am working with Yii and jQuery Mobile. I currently have 3 tables: Users, Projects and ShareProjects. I have been able to create a function to display shared projects with that user, but I am struggling to assign users to projects. I have tried this code but have been unsuccessful so far.</p>
  
  <pre><code>public function actionShareProjects() {  
     $model=new SharedProjects;
     if(isset($_POST['SharedProjects'])) {
        $model-&gt;attributes=$_POST['SharedProjects'];
        $model-&gt;project_id = "project_id";
        $model-&gt;user_id = "user_id";
        $model-&gt;sharedProject_id = "";
        $model-&gt;sharedCreateDate= date('Y-m-d G:i:s');
        if($model-&gt;save()) {
           echo json_encode(array('action'=&gt;'success', 'message'=&gt;''));
        } else {
            echo json_encode(array('action'=&gt;'error', 'message'=&gt;'Incorrect'));
        }
     }
  }
  </code></pre>
  
  <p>In the project, there is a share button which takes the project id but I am trying to be able to allow the user to type an email in for the user you would like to share with.</p>
  
  <p>I tried inputting it manually on postman but it failed, no errors came up but no data was saved. I used the correct input: </p>
  
  <pre><code>SharedProjects [user_id] 
  SharedProjects [project_id] 
  SharedProjects [sharedProject_id]
  SharedProjects [sharedCreateDate]
  </code></pre>